I'm trying to install the biopython module on my Ubuntu 12.04 LTS machine (64x). I first upgraded to Python3.3 by installing from source (biopython does not support other versions), that seems ok.

However, I installed some modules using the sudo apt-get install python-module command but I can't call them from a python shell:

dovah@AsusX501A:~$ python3.3
Python 3.3.5 (default, Mar 12 2014, 02:09:17)
[GCC 4.6.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from biopython import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'biopython'
>>> from Bio import * ##as suggested in http://biopython.org/DIST/docs/api/module-tree.html
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'Bio'

As you can see, the modules are installed:

dovah@AsusX501A:~$ sudo apt-get install python-biopython
Reading package lists... Done
Building dependency tree      
Reading state information... Done
python-biopython is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

And so is biopython (quite strange though: line 14 says biopython-1.64-py2.7-linux-x86_64.egg so best hit was found for version 2.7, not 3.3):

dovah@AsusX501A:~$ sudo easy_install -f http://biopython.org/DIST/ biopython
Searching for biopython
Reading http://biopython.org/DIST/
Best match: biopython 1.64
Downloading http://biopython.org/DIST/biopython-1.64.zip
Processing biopython-1.64.zip
Writing /tmp/easy_install-v5LJZz/biopython-1.64/setup.cfg
Running biopython-1.64/setup.py -q bdist_egg --dist-dir /tmp/easy_install-v5LJZz/biopython-1.64/egg-dist-tmp-TruGJH
warning: no previously-included files matching '.cvsignore' found under directory '*'
warning: no previously-included files matching '*.pyc' found under directory '*'
zip_safe flag not set; analyzing archive contents...
Bio.Entrez.Parser: module references __path__
Adding biopython 1.64 to easy-install.pth file
Installed /usr/local/lib/python2.7/dist-packages/biopython-1.64-py2.7-linux-x86_64.egg
Processing dependencies for biopython
Finished processing dependencies for biopython

Are modules specific for a given Python version? Is the system still stuck on Python 2.7? Obviousely I can't simply remove 2.7 unless I want to mess up my whole OS.

Thank you in advance for your help.

EDIT numpy successfully installed using: sudo apt-get install python3-numpy


Works perfectly, check it out. First command:

sudo apt-get install python3-pip

Second command:

pip3 install biopython
root@saurabh-ubuntu:/home/saurabh# apt-get install python-pip python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libexpat1-dev libpython3-dev libpython3.4-dev python-colorama python-distlib
  python-html5lib python-requests python-setuptools python-urllib3
  python3-colorama python3-dev python3-distlib python3-html5lib
  python3-setuptools python3.4-dev
Suggested packages:
Recommended packages:
The following NEW packages will be installed:
  libexpat1-dev libpython3-dev libpython3.4-dev python-colorama python-distlib
  python-html5lib python-pip python-requests python-setuptools python-urllib3
  python3-colorama python3-dev python3-distlib python3-html5lib python3-pip
  python3-setuptools python3.4-dev
0 upgraded, 17 newly installed, 0 to remove and 0 not upgraded.
Need to get 28.6 MB of archives.
After this operation, 48.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirror.team-cymru.org/ubuntu/ trusty/main libexpat1-dev amd64 2.1.0-4ubuntu1 [115 kB]
Get:2 http://mirror.team-cymru.org/ubuntu/ trusty/main libpython3.4-dev amd64 3.4.0-2ubuntu1 [27.0 MB]
Get:3 http://mirror.team-cymru.org/ubuntu/ trusty/main libpython3-dev amd64 3.4.0-0ubuntu2 [7,002 B]
Get:4 http://mirror.team-cymru.org/ubuntu/ trusty/universe python-colorama all 0.2.5-0.1ubuntu1 [18.3 kB]
Get:5 http://mirror.team-cymru.org/ubuntu/ trusty/universe python-distlib all 0.1.8-1 [113 kB]
Get:6 http://mirror.team-cymru.org/ubuntu/ trusty/main python-html5lib all 0.999-2 [83.2 kB]
Get:7 http://mirror.team-cymru.org/ubuntu/ trusty/main python-setuptools all 3.3-1ubuntu1 [230 kB]
Get:8 http://mirror.team-cymru.org/ubuntu/ trusty/main python-urllib3 all 1.7.1-1build1 [38.9 kB]
Get:9 http://mirror.team-cymru.org/ubuntu/ trusty/main python-requests all 2.2.1-1 [42.5 kB]
Get:10 http://mirror.team-cymru.org/ubuntu/ trusty/universe python-pip all 1.5.4-1 [97.7 kB]
Get:11 http://mirror.team-cymru.org/ubuntu/ trusty/universe python3-colorama all 0.2.5-0.1ubuntu1 [11.9 kB]
Get:12 http://mirror.team-cymru.org/ubuntu/ trusty/main python3.4-dev amd64 3.4.0-2ubuntu1 [425 kB]
Get:13 http://mirror.team-cymru.org/ubuntu/ trusty/main python3-dev amd64 3.4.0-0ubuntu2 [1,192 B]
Get:14 http://mirror.team-cymru.org/ubuntu/ trusty/universe python3-distlib all 0.1.8-1 [113 kB]
Get:15 http://mirror.team-cymru.org/ubuntu/ trusty/universe python3-html5lib all 0.999-2 [79.3 kB]
Get:16 http://mirror.team-cymru.org/ubuntu/ trusty/main python3-setuptools all 3.3-1ubuntu1 [144 kB]
Get:17 http://mirror.team-cymru.org/ubuntu/ trusty/universe python3-pip all 1.5.4-1 [80.4 kB]
Fetched 28.6 MB in 2min 18s (207 kB/s)                                         
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 260300 files and directories currently installed.)
Preparing to unpack .../libexpat1-dev_2.1.0-4ubuntu1_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-4ubuntu1) ...
Selecting previously unselected package libpython3.4-dev:amd64.
Preparing to unpack .../libpython3.4-dev_3.4.0-2ubuntu1_amd64.deb ...
Unpacking libpython3.4-dev:amd64 (3.4.0-2ubuntu1) ...
Selecting previously unselected package libpython3-dev:amd64.
Preparing to unpack .../libpython3-dev_3.4.0-0ubuntu2_amd64.deb ...
Unpacking libpython3-dev:amd64 (3.4.0-0ubuntu2) ...
Selecting previously unselected package python-colorama.
Preparing to unpack .../python-colorama_0.2.5-0.1ubuntu1_all.deb ...
Unpacking python-colorama (0.2.5-0.1ubuntu1) ...
Selecting previously unselected package python-distlib.
Preparing to unpack .../python-distlib_0.1.8-1_all.deb ...
Unpacking python-distlib (0.1.8-1) ...
Selecting previously unselected package python-html5lib.
Preparing to unpack .../python-html5lib_0.999-2_all.deb ...
Unpacking python-html5lib (0.999-2) ...
Selecting previously unselected package python-setuptools.
Preparing to unpack .../python-setuptools_3.3-1ubuntu1_all.deb ...
Unpacking python-setuptools (3.3-1ubuntu1) ...
Selecting previously unselected package python-urllib3.
Preparing to unpack .../python-urllib3_1.7.1-1build1_all.deb ...
Unpacking python-urllib3 (1.7.1-1build1) ...
Selecting previously unselected package python-requests.
Preparing to unpack .../python-requests_2.2.1-1_all.deb ...
Unpacking python-requests (2.2.1-1) ...
Selecting previously unselected package python-pip.
Preparing to unpack .../python-pip_1.5.4-1_all.deb ...
Unpacking python-pip (1.5.4-1) ...
Selecting previously unselected package python3-colorama.
Preparing to unpack .../python3-colorama_0.2.5-0.1ubuntu1_all.deb ...
Unpacking python3-colorama (0.2.5-0.1ubuntu1) ...
Selecting previously unselected package python3.4-dev.
Preparing to unpack .../python3.4-dev_3.4.0-2ubuntu1_amd64.deb ...
Unpacking python3.4-dev (3.4.0-2ubuntu1) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../python3-dev_3.4.0-0ubuntu2_amd64.deb ...
Unpacking python3-dev (3.4.0-0ubuntu2) ...
Selecting previously unselected package python3-distlib.
Preparing to unpack .../python3-distlib_0.1.8-1_all.deb ...
Unpacking python3-distlib (0.1.8-1) ...
Selecting previously unselected package python3-html5lib.
Preparing to unpack .../python3-html5lib_0.999-2_all.deb ...
Unpacking python3-html5lib (0.999-2) ...
Selecting previously unselected package python3-setuptools.
Preparing to unpack .../python3-setuptools_3.3-1ubuntu1_all.deb ...
Unpacking python3-setuptools (3.3-1ubuntu1) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../python3-pip_1.5.4-1_all.deb ...
Unpacking python3-pip (1.5.4-1) ...
Processing triggers for doc-base (0.10.5) ...
Processing 1 added doc-base file...
Processing triggers for man-db ( ...
Setting up libexpat1-dev:amd64 (2.1.0-4ubuntu1) ...
Setting up libpython3.4-dev:amd64 (3.4.0-2ubuntu1) ...
Setting up libpython3-dev:amd64 (3.4.0-0ubuntu2) ...
Setting up python-colorama (0.2.5-0.1ubuntu1) ...
Setting up python-distlib (0.1.8-1) ...
Setting up python-html5lib (0.999-2) ...
Setting up python-setuptools (3.3-1ubuntu1) ...
Setting up python-urllib3 (1.7.1-1build1) ...
Setting up python-requests (2.2.1-1) ...
Setting up python-pip (1.5.4-1) ...
Setting up python3-colorama (0.2.5-0.1ubuntu1) ...
Setting up python3.4-dev (3.4.0-2ubuntu1) ...
Setting up python3-dev (3.4.0-0ubuntu2) ...
Setting up python3-distlib (0.1.8-1) ...
Setting up python3-html5lib (0.999-2) ...
Setting up python3-setuptools (3.3-1ubuntu1) ...
Setting up python3-pip (1.5.4-1) ...
root@saurabh-ubuntu:/home/saurabh# pip3 install biopython
Downloading/unpacking biopython
  Downloading biopython-1.64.tar.gz (11.7MB): 11.7MB downloaded
  Running setup.py (path:/tmp/pip_build_root/biopython/setup.py) egg_info for package biopython

    warning: no previously-included files matching '.cvsignore' found under directory '*'
    warning: no previously-included files matching '*.pyc' found under directory '*'
Installing collected packages: biopython
  Running setup.py install for biopython
    building 'Bio.cpairwise2' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c Bio/cpairwise2module.c -o build/temp.linux-x86_64-3.4/Bio/cpairwise2module.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/Bio/cpairwise2module.o -o build/lib.linux-x86_64-3.4/Bio/cpairwise2.cpython-34m.so
    building 'Bio.trie' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -IBio -I/usr/include/python3.4m -c Bio/triemodule.c -o build/temp.linux-x86_64-3.4/Bio/triemodule.o
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -IBio -I/usr/include/python3.4m -c Bio/trie.c -o build/temp.linux-x86_64-3.4/Bio/trie.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/Bio/triemodule.o build/temp.linux-x86_64-3.4/Bio/trie.o -o build/lib.linux-x86_64-3.4/Bio/trie.cpython-34m.so
    building 'Bio.Nexus.cnexus' extension
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.4m -c Bio/Nexus/cnexus.c -o build/temp.linux-x86_64-3.4/Bio/Nexus/cnexus.o
    x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.4/Bio/Nexus/cnexus.o -o build/lib.linux-x86_64-3.4/Bio/Nexus/cnexus.cpython-34m.so

    warning: no previously-included files matching '.cvsignore' found under directory '*'
    warning: no previously-included files matching '*.pyc' found under directory '*'
Successfully installed biopython
Cleaning up...
root@saurabh-ubuntu:/home/saurabh# python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import Bio
[3]+  Stopped                 python3
  • pip successfully downloaded, executed and installed. However, I get sudo: pip-3.3: command not found for the biopython installation. – dovah Jul 22 '14 at 14:07
  • then try sudo pip3 install biopython – Saurabh Jul 22 '14 at 14:08
  • I get errors. Please refer to my comments on @Salem's answers to this question. – dovah Jul 22 '14 at 14:15
  • The name of the module is Bio. So use import Bio – Saurabh Jul 22 '14 at 14:23
  • As you can see in my posted question, Bio isn't recognized as module under python3.3. And it isn't configured for python3.2, which I installed from Synaptic. I had to upgrade, so I installed version 3.3 from source because Synaptic doesn't include it. So maybe this is the main problem. In fact, /usr/bin/python3 gives me back python3.2 by default. Any ideas for fixing this? – dovah Jul 22 '14 at 14:28

Usually python-* packages are targeted to Python 2.X. The ones to Python 3 are named python3-*.

In your case the package you need is not available, so you will need to install it "manually".

This can be easily achieved with the following:

$ sudo apt-get install python3-dev python3-pip
$ sudo pip3 install biopython

If you dont want it to be installed system-wide you can use a virtualenv:

$ virtualenv -p python3.3 some_location  # replace 3.3 with your version. 
$ source some_location/bin/activate
$ pip install biopython # python3-dev should be already installed.
  • I tried your suggestion, but on sudo pip3 install biopython I get the following error: Cleaning up... Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/biopython Storing debug log for failure in /home/dovah/.pip/pip.log. It seems not detecting my installed version 3.3 – dovah Jul 22 '14 at 13:47
  • Other remark: my system is running on 12.04LTS, so I had to sudo apt-get install python3-setuptools & sudo easy_install3 pip3 (python3-pip isn't available for distros before 13.04) – dovah Jul 22 '14 at 13:50
  • Can you post the output in ~/.pip/pip.log? – Salem Jul 22 '14 at 13:55
  • Actually, bash: cd: /home/dovah/.pip/pip.log: Not a directory – dovah Jul 22 '14 at 14:03
  • Sorry, what I meant was the contents of the file: cat ~/.pip/pip.log. – Salem Jul 22 '14 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.