This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Biopython: ImportError: No module named TreeConstruction

Hi to all! Someone knows why I get the following error?

>>> from Bio.Phylo.TreeConstruction import DistanceCalculator, DistanceTreeConstructor

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    import Bio.Phylo.TreeConstruction
ImportError: No module named TreeConstruction

And also:

>>> from Bio.Phylo.Consensus import *

Traceback (most recent call last):
  File "<pyshell#9>", line 1, in <module>
    from Bio.Phylo.Consensus import *
ImportError: No module named Consensus

Thanks to all for you time =)

python software-error biopython

2 answers

Which version of BioPython are you using ? You can check version:

python -c 'import Bio; print Bio.__version__'
python -c 'from Bio.Phylo.TreeConstruction import DistanceCalculator, DistanceTreeConstructor'

is working in BioPython 1.65.

version 1.65. But this is weird, it works in the terminal, but not in the python IDLE !

Ok. Fixed!

The problem was that in the python IDLE, the version of biopython was 1.63, whereas the code

>>>from Bio.Phylo.TreeConstruction import DistanceCalculator, DistanceTreeConstructor

works nice for version 1.65. So, the solution was delete the folder where biopython 1.63 was installed and download and later (re)install the biopython 1.65.

Good to know it works now. :)

Log in to answer this question.