我正在尝试在我的 Ubuntu 12.04 LTS 机器 (64x) 上安装 biopython 模块。我首先通过从源代码安装升级到 Python3.3 (biopython 不支持其他版本),这似乎没问题。
但是,我使用命令安装了一些模块sudo apt-get install python-module
,但无法从 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'
如你所见,模块已经安装:
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.
biopython 也是如此(不过很奇怪:第 14 行说biopython-1.64-py2.7-linux-x86_64.egg
最佳匹配是针对版本 2.7,而不是 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
模块是否特定于给定的 Python 版本?系统是否仍停留在 Python 2.7 上?显然,除非我想弄乱我的整个操作系统,否则我不能简单地删除 2.7。
预先感谢您的帮助。
编辑
numpy 已成功安装,使用方法如下:sudo apt-get install python3-numpy
答案1
运行完美,检查一下。第一个命令:
sudo apt-get install python3-pip
第二条命令:
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:
python-genshi
Recommended packages:
python-dev-all
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 (2.6.7.1-1) ...
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
root@saurabh-ubuntu:/home/saurabh#
答案2
通常python-*
软件包针对的是 Python 2.X。针对 Python 3 的软件包名为python3-*
。
就您而言,您需要的包不可用,因此您需要“手动”安装它。
通过以下方式可以轻松实现这一点:
$ sudo apt-get install python3-dev python3-pip
$ sudo pip3 install biopython
如果你不想在整个系统范围内安装它,你可以使用虚拟环境:
$ 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.