[BioPython] Weird biopython bug

Jeffrey Chang jeffrey_chang at stanfordalumni.org
Tue Jun 1 16:19:50 EDT 2004


sophie:~ jchang$ python
Python 2.3.2 (#1, Nov 18 2003, 16:29:33)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import Bio
 >>> dir(Bio)['WWW', '__builtins__', '__doc__', '__file__', '__name__', 
'__path__', 'config', 'db', 'formats', 'seqdb']
 >>>


On Jun 1, 2004, at 3:49 PM, Gavin Crooks wrote:

> I've run into the following weird error; I can't import Bio.Fasta
>
>
>> >>> from Bio import Fasta
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in ?
>>   File "/Users/gec/CVSWork/biopython/Bio/Fasta/__init__.py", line 19, 
>> in ?
>>     from Bio import SeqRecord
>>   File "/Users/gec/CVSWork/biopython/Bio/SeqRecord.py", line 11, in ?
>>     default_output_format = "fasta")
>>   File "/Users/gec/CVSWork/biopython/Bio/Bio/FormatIO.py", line 55, 
>> in __init__
>>     registery = Bio.formats
>> AttributeError: 'module' object has no attribute 'formats'

That's really strange.  Is there any chance you are using an out of 
date version of biopython, or that the biopython distribution is out of 
sync, or that there are multiple biopython installations?

This line in particular is weird:
>>   File "/Users/gec/CVSWork/biopython/Bio/Bio/FormatIO.py", line 55, 
>> in __init__

Is there really a Bio/Bio/FormatIO.py file?


> This fails whenever 'registery' is None since Bio.formats does not 
> appear to exist.

There's a function under Bio/__init__.py that loads the various 
registries under Bio/config, which contains code to download database 
records and parse them.  It pulls the registries under the Bio 
namespace, thus Bio.formats actually comes from 
Bio/config/FormatRegistry.py.  If the file is missing, biopython won't 
be able to find it, and thus, no Bio.formats, and you get a traceback.

Try running the following lines to see whether you are importing the 
files you expect, and whether the correct objects are getting pulled 
into the Bio namespace.

sophie:~ jchang$ python
Python 2.3.2 (#1, Nov 18 2003, 16:29:33)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import Bio
 >>> dir(Bio)
['WWW', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 
'config', 'db', 'formats', 'seqdb']
 >>> Bio.__file__
'/Users/jchang/lib/jchang/python/Bio/__init__.pyc'
 >>> import Bio.config.FormatRegistry
 >>> Bio.config.FormatRegistry.__file__
'/Users/jchang/lib/jchang/python/Bio/config/FormatRegistry.pyc'
 >>>

Jeff



More information about the BioPython mailing list