OB— title: Getting Started permalink: wiki/Getting_Started layout: wiki —
Download and Installation
For Windows we provide click-and-run installers. Most Linux distributions will include an optional Biopython package (although this may be out of date). Otherwise you typically download and uncompress the archive, and install from source. See our downloads page for details including the prerequisites.
You can check your installation has worked at the python prompt:
>>> import BioIf that gives no error, you should be done. If you get something like “ImportError: No module named Bio” something has gone wrong. Note the case is important.
Tutorial
The Biopython Tutorial and Cookbook (HTML, PDF) contains the bulk of our documentation. See Documentation for more links.
Quick example
Try executing this in python:
from Bio.Seq import Seq # create a sequence object my_seq = Seq("CATGTAGACTAG") # print out some details about it print("seq %s is %i bases long" % (my_seq, len(my_seq))) print("reverse complement is %s" % my_seq.reverse_complement()) print("protein translation is %s" % my_seq.translate())
You should get the following output:
seq CATGTAGACTAG is 12 bases long reverse complement is CTAGTCTACATG protein translation is HVD*
This was a very quick demonstration of Biopython’s Seq (sequence) object and some of its methods.
Reading and writing Sequence Files
Use the SeqIO module for reading or writing sequences as SeqRecord objects. For multiple sequence alignment files, you can alternatively use the AlignIO module.
Beginners
- Learn how to program in Python
- A Byte of Python
- Dive Into Python
- Python Quick Reference
- Browse the Biopython Tutorial
- Read this paper Bassi2007 pmid=18052533
- Examine the Class Diagram if you’d like to know more about the relationships between the modules.
Further reading
- Use the Wiki Search tools to find more information on specific topics.
FYI: this is NOT a duplicate!
Before running my python code I installed biopython in the cmd prompt:
pip install biopythonI then get an error saying 'No module named Bio' when try to import it in python
import BioThe same thing happens with
import biopythonIt should be noted I have updated PIP and run python 3.5.2
I appreciate anyone's help.
Chris_Rands
36.2k12 gold badges78 silver badges110 bronze badges
asked Apr 16, 2018 at 1:33
4
use this:
pip3 install biopython
and then import Bio worked for me
answered Apr 16, 2018 at 1:37
4
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. :)
answered Oct 31, 2019 at 20:33
Nina MBNina MB
671 silver badge3 bronze badges
1
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.
answered Dec 4, 2019 at 21:19
pip3 ❌ didn't fully work for me as there was a problem with importing a function.
conda install biopython✔️ worked for me.
answered Mar 25, 2020 at 20:18
banan3'14banan3'14
3,0573 gold badges20 silver badges44 bronze badges
Rename the site-package name from bio into Bio
C:\Users\user\Anaconda3\Lib\site-packages\bio C:\Users\user\Anaconda3\Lib\site-packages\Bioit works for me!
answered Mar 19, 2020 at 9:09
1
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
answered Mar 4, 2020 at 15:51
cfcalcfcal
1616 bronze badges
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
answered Mar 17, 2021 at 4:02
In my case (MacOS X Catalina, python 3.7.6 installed by brew), I had to install it with
python -m pip install Bio(uppercase) but use it with
from bio import pairwise2and the worse is that I had to change the code of the package: I went into python3.7/site-packages/bio/pairwise2.py, line 246, changed
from Bio import BiopythonWarninginto
from bio import BiopythonWarningI hate changing the code of the package, on the next update it won't work again… Please do something to fix this bio/Bio issue.
answered Feb 15, 2020 at 23:29
yannisyannis
8669 silver badges24 bronze badges
I had the same error. it turns out
import Bio
works
instead of import biopython !
answered Mar 27, 2020 at 23:06
In my case, i got an error while trying to install BioPython, "BioPython requires python version greater than 3.6"
So installing the latest version fixed it for me.
answered Jun 9, 2020 at 16:36
I could not import biopython when running python on windows.
I tried several solutions by changing the directory names to upper/lower case as //stackoverflow.com/a/60753930/10884907 and also different way of calling when import using "Bio", "bio", "biopyhton". None was working.
But, It works in linux as simple as in manual guideliens, I did pip3 install biopython and with import Bio works!
answered Jul 27, 2020 at 10:02
I tried pip3 install biopython but it didn't work for me.
But this works! - !pip install biopython
answered Oct 23, 2020 at 17:30
I tried all of the above with no success. I switched from Python 3.8 to Python 3 and that worked.
answered Mar 20, 2021 at 23:53
If you encounter this problem now and find your python version to be higher than 3.8: create a virtual environment, downgrade python to 3.8 and if you are using jupyter notebook, install it again in your environment..
answered Dec 1, 2021 at 14:12