Question: ModuleNotFoundError: No module named 'Bio'
0
gravatar for alissamariewilliams2015
9 months ago by

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 import python • 5.5k views
ADD COMMENTlink modified 9 months ago by Brice Sarver3.5k • written 9 months ago by alissamariewilliams20150
1

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 REPLYlink written 9 months ago by Arup Ghosh2.4k

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 REPLYlink modified 9 months ago by ATpoint35k • written 9 months ago by alissamariewilliams20150

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 REPLYlink written 9 months ago by alissamariewilliams20150
2

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

ADD REPLYlink written 9 months ago by Arup Ghosh2.4k

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 REPLYlink written 9 months ago by alissamariewilliams20150
1
gravatar for Brice Sarver
9 months ago by
Brice Sarver3.5k
United States
Brice Sarver3.5k wrote:

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 COMMENTlink written 9 months ago by Brice Sarver3.5k
1

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 REPLYlink modified 9 months ago • written 9 months ago by ATpoint35k

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 REPLYlink written 9 months ago by Brice Sarver3.5k

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 REPLYlink written 9 months ago by alissamariewilliams20150
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: 2145 users visited in the last hour