[BioPython] from Bio import db

Peter biopython at maubp.freeserve.co.uk
Thu Nov 8 12:14:18 UTC 2007


>> ImportError: cannot import name db
> 
> It looks like we missed an "import db" statement in Bio/GenBank/__init__.py.
> Can you show us the code leading up to this point? I'm guessing that you are
> trying to use NCBIDictionary, but it would be helpful to see how exactly you
> are trying to use it, so that we can come up with a solution.
> 
> Sorry for the trouble.

I think the problem was introduced in Biopython 1.44 by disabling some 
"magic" code in Bio/__init__.py which created Bio.db at runtime, which 
was then imported in Bio/GenBank/__init__.py

The following one line patch to the NCBIDictionary class in 
Bio/GenBank/__init__.py seems to fix this:

diff -r1.77 __init__.py
1283c1283
<         from Bio import db
---
 >         from Bio.config.DBRegistry import db

i.e. change line 1293 from "from Bio import db" to "from 
Bio.config.DBRegistry import db" in the NCBIDictionary class.

Eric, could you try this on your setup?

Peter

Note to self: We need to add the NCBIDictionary to the GenBank unit test




More information about the Biopython mailing list