Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

biopython no module named Bio

FYI: this is NOT a duplicate!

Before running my python code I installed biopython in the cmd prompt:

pip install biopython

I then get an error saying 'No module named Bio' when try to import it in python

import Bio

The same thing happens with

import biopython     

It should be noted I have updated PIP and run python 3.5.2
I appreciate anyone's help.

like image 359
Gabriel Avatar asked Apr 16 '18 01:04

Gabriel


People also ask

How do I know if Biopython is installed?

3. Confirm that Biopython has been correctly installed by starting a Python terminal session and entering this line: import Bio If you do not receive an error message, then Biopython has been properly installed!

Is Biopython a module?

Basically, Biopython is a collection of python modules that provide functions to deal with DNA, RNA & protein sequence operations such as reverse complementing of a DNA string, finding motifs in protein sequences, etc.

How do I install Biopython in Anaconda?

Install Anaconda Navigator, go to " Environments " and select the appropriate environment (base or your own) and click " not installed ". Scroll down to biopython click the box and then install...


7 Answers

use this:

pip3 install biopython

and then import Bio worked for me

like image 157
Tanay Agrawal Avatar answered Oct 10 '22 18:10

Tanay Agrawal


When I came across this problem I noticed that after I installed biopython using pip install biopython the module directory in the site-packages folder was written with lowercase instead of uppercase letters. All in all, the folder was named bio instead Bio, so I just renamed the folder and everything started to work just fine. I am new to programing so I am aware this isn't the most elegant solution but it worked for me so I hope my answer will be useful to some of you. :)

like image 43
Nina MB Avatar answered Oct 10 '22 16:10

Nina MB


I just hit this issue with the problem being lower-case bio vs upper-case Bio. Turns out the problem was that it installs differently on python 2 and 3. In Python 2 you do import Bio, but in python 3 import bio. If you're hitting this issue it might be for the same reason, and the solution is probably to make sure you use the right name for the Python version you're on.

like image 43
Gil Goldshlager Avatar answered Oct 10 '22 16:10

Gil Goldshlager


pip3didn't fully work for me as there was a problem with importing a function.

conda install biopython 

✔️ worked for me.

like image 33
banan3'14 Avatar answered Oct 10 '22 17:10

banan3'14


Rename the site-package name from bio into Bio

C:\Users\user\Anaconda3\Lib\site-packages\bio

C:\Users\user\Anaconda3\Lib\site-packages\Bio

it works for me!

like image 43
Xie Avatar answered Oct 10 '22 18:10

Xie


On windows it installs the bio package in a top level directory named bio with lower case b. To fix the problem rename the directory to upper case b, Bio.

Obviously the biopython people don't pay much attention to the win

like image 29
cfcal Avatar answered Oct 10 '22 16:10

cfcal


As stated by others Biopython appears to work only with python 3.5. In my current environment I had python 2.7, so creating a Conda environment with python 3.5 solved the problem for me.

conda create -n mypython3.5 python=3.5

Then activate the environment:

conda activate mypython3.5

And installing Biopython on it:

conda install -c conda-forge biopython

In my case I also had to install Prodigal in the new environment to run my script:

conda install -c bioconda prodigal

like image 34
Alejandro Avatar answered Oct 10 '22 16:10

Alejandro