ModuleNotFoundError: No module named 'Bio'
1
0
Entering edit mode
4.7 years ago

Can anyone help me with this? I am at my wit's end.

I recently got a new computer (mac), and installed Python via Anaconda. I was able to use biopython no problem yesterday with the import statement:

from Bio import SeqIO

However, today I was trying to use a function in the package Phylo. At first I didn't realize it was part of biopython, so I tried:

import phylo

When that didn't work, I tried to install it:

python -m pip install phylo

which of course didn't work. The output of that command was:

Collecting phylo
  ERROR: Could not find a version that satisfies the requirement phylo (from versions: none)
ERROR: No matching distribution found for phylo

I then went back into a Python shell and typed:

import Bio

which gave me the error:

ModuleNotFoundError: No module named 'Bio'

Thus, I tried to install biopython using:

python -m pip install Bio

After that, I still got the "No module called 'Bio'" error in the Python shell. I have since tried to install/reinstall biopython in a bunch of different ways, to no avail. Here's what I've tried:

python -m pip install biopython
pip install biopython
pip install biopython --upgrade
pip3 install biopython (didn't work at all)
pip install biopython --user

Except in the case of the pip3 command, which didn't work at all, every installation said it was successful. And yet I STILL can't import Bio. I also can't import it as biopython. The statement:

import bio

did work, but none of the needed packages are included.

Please advise. I really need biopython to work and I'm ready to scream.

biopython Python import Biopython • 24k views
ADD COMMENT
1
Entering edit mode

Open a terminal and check the python version with python -V, if the default python version is 2.7 pip 3 will not work and also check if the Python form Anaconda is set as default in bash profile.

ADD REPLY
0
Entering edit mode

I only have python 3 on this computer, so I don't think that's the issue:

python -V
Python 3.7.3

which pip
/Users/alissawilliams/anaconda3/bin/pip

pip --version
pip 19.1.1 from /Users/alissawilliams/anaconda3/lib/python3.7/site-packages/pip (python 3.7)

more .bash_profile 
# added by Anaconda3 2019.07 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/alissawilliams/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
    \eval "$__conda_setup"
else
    if [ -f "/Users/alissawilliams/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/alissawilliams/anaconda3/etc/profile.d/conda.sh"
        CONDA_CHANGEPS1=false conda activate base
    else
        \export PATH="/Users/alissawilliams/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda init <<<
ADD REPLY
0
Entering edit mode

In the directory: /Users/alissawilliams/anaconda3/lib/python3.7/site-packages/

all of these are listed: bio bio-0.1.0.dist-info biopython-1.74.dist-info

in case that's any help.

ADD REPLY
2
Entering edit mode

Try /Users/alissawilliams/anaconda3/bin/pip install --upgrade --force-reinstall biopython and start a python shell by /Users/alissawilliams/anaconda3/bin/python .

ADD REPLY
0
Entering edit mode

This didn't work either. :( I don't know what happened to my biopython, and I've tried every install command known to man at this point. For what it's worth, I can import other modules, just not biopython (for instance, numpy works fine).

ADD REPLY
1
Entering edit mode
4.7 years ago
Brice Sarver ★ 3.8k

Others may be able to help you troubleshoot, but this sounds like an issue related to your system configuration. It looks like you're using conda, so I'd recommend creating a new environment through that and installing biopython from one of the official channels. My recommendation would be to set up the channel hierarchy as instructed through Bioconda and use their package, just to make sure things go smoothly.

ADD COMMENT
1
Entering edit mode

I am not an experienced python user but isn't pip installing things into .local which by default is not in PATH (or the python-ish equivalent)? I would start by checking if your python knows where to look for these packages and extensions.

ADD REPLY
1
Entering edit mode

You're generally right, but conda adds a layer of complexity by appending to $PATH when an environment is activated. I can't easily troubleshoot without logging into the system and seeing what's going on, but it sounds like OP got it figured out with my suggestion.

ADD REPLY
0
Entering edit mode

Hi all-

I ended up installing all packages named "bio-something" in site-packages and then tried the conda command: conda install -c anaconda biopython

And I can now import Bio. Thanks for the help, everyone!

ADD REPLY
0
Entering edit mode

this worked for me thanks all!

ADD REPLY

Login before adding your answer.

Traffic: 4034 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6