Question: Error importing Biopython module
0
gravatar for pmr
4.7 years ago by
pmr0
Uppsala, Sweden
pmr0 wrote:

I want to do a cluster analysis using the distance functions in Biopython. But, the following line of code:

from Bio.Cluster import distancematrix

results in the following error:

ImportError: No module named 'Bio.Cluster'

Does anyone have an idea why this might happen?

biopython python 3 python • 4.3k views
ADD COMMENTlink modified 23 days ago by kalilamali0 • written 4.7 years ago by pmr0

What operating system do you use? Did you install Biopython correctly? Does this happen when you try to import other Biopython components (eg. import Bio) or is this specific to the Cluster module?
 

ADD REPLYlink written 4.7 years ago by lelle800

I use OSX. Yes I think Biopython is correctly installed, because I am able to import other modules so I suspect this is specific for Bio.Cluster. The following, for example, works fine:

from Bio.Seq import Seq
from Bio.Alphabet import IUPAC

 

ADD REPLYlink written 4.7 years ago by pmr0

This looks like a problem with the Bio.Cluster package. We should wait for someone from the Bio Cluster team to take a look at this post.

ADD REPLYlink written 4.7 years ago by RamRS24k
2
gravatar for Peter
4.7 years ago by
Peter5.8k
Scotland, UK
Peter5.8k wrote:

One possible problem is that you installed Biopython without having NumPy. This would result in not installing the cluster module which uses C code with NumPy. If so, you may need to reinstall Biopython. If this is the problem this won't work either:

from Bio import KDTree

Alternatively, it might be you didn't install Biopython properly and have somehow managed to get access to only the pure-Python parts? That is possible if you're in the Biopython source code directory when you run Python, or if you have set the $PYTHONPATH to include the Biopython source code. In this case the following will probably also fail:

from Bio import trie

In addition to trying these two imports, could you add more details about how you installed Biopython? e.g. Which version of OS X, XCode, Python, NumPy, Biopython.

ADD COMMENTlink written 4.7 years ago by Peter5.8k

I reinstalled Biopython and I no longer get the import error! Thanks for all your suggestions.

I did get quite a few warnings when reinstalling Biopython (using easyinstaller), do you have any thoughts on why I get these? Could they be related to the import issue?

Searching for biopython
Reading http://biopython.org/DIST/
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/setuptools-12.0.5-py3.4.egg/pkg_resources/__init__.py:2510: PEP440Warning: 'biopython (corba-0.2.1)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/setuptools-12.0.5-py3.4.egg/pkg_resources/__init__.py:2510: PEP440Warning: 'biopython (corba-0.3.0)' is being parsed as a legacy, non PEP 440, version. You may find odd behavior and sort order. In particular it will be sorted as less than 0.0. It is recommend to migrate to PEP 440 compatible versions.
Best match: biopython 1.65
Downloading http://biopython.org/DIST/biopython-1.65.zip
Processing biopython-1.65.zip
Writing /tmp/easy_install-jqt75dle/biopython-1.65/setup.cfg
Running biopython-1.65/setup.py -q bdist_egg --dist-dir /tmp/easy_install-jqt75dle/biopython-1.65/egg-dist-tmp-jgo6r6jw
warning: no previously-included files matching '.cvsignore' found under directory '*'
warning: no previously-included files matching '*.pyc' found under directory '*'
ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/cpairwise2module.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/cpairwise2module.o
ld: warning: ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/triemodule.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/triemodule.oignoring file build/temp.macosx-10.6-intel-3.4/Bio/trie.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/trie.o

ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/Nexus/cnexus.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/Nexus/cnexus.o
ld: warning: ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/Cluster/clustermodule.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/Cluster/clustermodule.oignoring file build/temp.macosx-10.6-intel-3.4/Bio/Cluster/cluster.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/Cluster/cluster.o

ld: warning: ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/KDTree/KDTree.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/KDTree/KDTree.oignoring file build/temp.macosx-10.6-intel-3.4/Bio/KDTree/KDTreemodule.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/KDTree/KDTreemodule.o

ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/Motif/_pwm.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/Motif/_pwm.o
ld: warning: ignoring file build/temp.macosx-10.6-intel-3.4/Bio/motifs/_pwm.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): build/temp.macosx-10.6-intel-3.4/Bio/motifs/_pwm.o
zip_safe flag not set; analyzing archive contents...
Bio.__pycache__.cpairwise2.cpython-34: module references __file__
Bio.__pycache__.trie.cpython-34: module references __file__
Bio.Cluster.__pycache__.cluster.cpython-34: module references __file__
Bio.Entrez.__pycache__.Parser.cpython-34: module references __path__
Bio.KDTree.__pycache__._CKDTree.cpython-34: module references __file__
Bio.Motif.__pycache__._pwm.cpython-34: module references __file__
Bio.motifs.__pycache__._pwm.cpython-34: module references __file__
Bio.Nexus.__pycache__.cnexus.cpython-34: module references __file__
creating /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/biopython-1.65-py3.4-macosx-10.6-intel.egg
Extracting biopython-1.65-py3.4-macosx-10.6-intel.egg to /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages
Adding biopython 1.65 to easy-install.pth file

Installed /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/biopython-1.65-py3.4-macosx-10.6-intel.egg
Processing dependencies for biopython
Finished processing dependencies for biopython
ADD REPLYlink written 4.7 years ago by pmr0

We don't recommend easyinstallster, and I'm not vary familiar with it. The warning about biopython (corba-0.3.0) is puzzling, not sure where that could be coming from? But in any case, reinstalling seems to have worked?

ADD REPLYlink written 4.7 years ago by Peter5.8k

Yes it has worked fine since I reinstalled. Thank you.

ADD REPLYlink written 4.7 years ago by pmr0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1301 users visited in the last hour