Search code examples
pythonimporterrorskbio

ImportError for skbio module


I am running Python 3 and have skbio v0.5.5 installed. Following the examples in this tutorial, I am trying to run the import statements for some skbio classes, but am getting errors. For example,

from skbio.alignment import Alignment

results in

ImportError: cannot import name 'Alignment' from 'skbio.alignment'

Also,

from skbio import BiologicalSequence

results in

ImportError: cannot import name 'Alignment' from 'BiologicalSequence'

How do I resolve this?


Solution

  • The Alignment class is from an older version of the skbio library, specifically from before version 0.3.

    If you would like to use those classes, you would need to install scikit-bio from before that version, by doing something like:

    pip install scikit-bio==0.2
    

    If you're just going through the Introduction to Applied Bioinformatics book, like you mentioned in your comment, it's better to use the latest version of the book instead, which will use the latest version of the scikit-bio library.