Biopython - Installation



This section explains how to install Biopython on your machine. It is very easy to install and it will not take more than five minutes.

A virtual environment allows us to create an isolated working copy of python for a specific project without affecting the outside setup.

We shall use venv module in Python's standard library to create virtual environment. PIP is included by default in Python version 3.4 or later.

Use the following command to create virtual environment in Windows

D:\biopython>py -m venv myenv

On Ubuntu Linux, update the APT repo and install venv if required before creating virtual environment

mvl@GNVBGL3:~ $ sudo apt update && sudo apt upgrade -y
mvl@GNVBGL3:~ $ sudo apt install python3-venv

Then use the following command to create a virtual environment

mvl@GNVBGL3:~ $ sudo python3 -m venv myenv

You need to activate the virtual environment. On Windows use the command

D:\biopython>cd myenv
D:\biopython\myenv>scripts\activate
(myenv) D:\biopython\myenv>

On Ubuntu Linux, use following command to activate the virtual environment

mvl@GNVBGL3:~$ cd myenv
mvl@GNVBGL3:~/myenv$ source bin/activate
(myenv) mvl@GNVBGL3:~/myenv$

Name of the virtual environment appears in the parenthesis. Now that it is activated, we can now install BioPython in it.

D:\biopython\myenv> pip3 install biopython

(myenv) D:\biopython\myenv>pip3 install biopython
Collecting biopython
  Obtaining dependency information for biopython from https://files.pythonhosted.org/packages/a9/13/00db03b01e54070d5b0ec9c71eef86e61afa733d9af76e5b9b09f5dc9165/biopython-1.86-cp312-cp312-win_amd64.whl.metadata
  Downloading biopython-1.86-cp312-cp312-win_amd64.whl.metadata (13 kB)
Collecting numpy (from biopython)
  Obtaining dependency information for numpy from https://files.pythonhosted.org/packages/2d/57/8aeaf160312f7f489dea47ab61e430b5cb051f59a98ae68b7133ce8fa06a/numpy-2.3.5-cp312-cp312-win_amd64.whl.metadata
  Downloading numpy-2.3.5-cp312-cp312-win_amd64.whl.metadata (60 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.9/60.9 kB 1.1 MB/s eta 0:00:00
Downloading biopython-1.86-cp312-cp312-win_amd64.whl (2.7 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.7/2.7 MB 7.9 MB/s eta 0:00:00
Downloading numpy-2.3.5-cp312-cp312-win_amd64.whl (12.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.8/12.8 MB 8.8 MB/s eta 0:00:00
Installing collected packages: numpy, biopython
Successfully installed biopython-1.86 numpy-2.3.5

Verify Biopython Installation

Now, you have successfully installed Biopython on your machine. To verify that Biopython is installed properly, type the below command on your python console −

(myenv) D:\biopython\myenv>py
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Bio
>>> print(Bio.__version__)
1.86
>>>

It shows the version of Biopython.

As of now, the latest version is biopython-1.86.

Advertisements