安装HTSeq,需要Python版本在2.5以上(但是在Python 3下不行),并且需要安装NumPy。如果已经安装了NumPy的话,安装HTSeq并不困难。但是如果没有安装的话,可能会比较麻烦。
首先,需要安装python 2.5以上的版本。因为centOS 5所带的Python版本是2.4,无法满足HTSeq的安装要求。但是,我并不建议直接升组安装python2.5以上的版本,因为yum等很多功能都由python来实现,所以我的办法是全新安装一个python的版本到一个指定的目录下面去。
下载并安装Python 2.7.2.
[ouj@qiuworld.com ~]$ tar -xzvf Python-2.7.2.tgz [ouj@qiuworld.com ~]$ cd Python-2.7.2 [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tcl #需要安装tcl/tk库 [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tcl-devel [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tk [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tk-devel [ouj@qiuworld.com Python-2.7.2]$ ./configure --prefix=/opt/python2.7 --with-threads --enable-shared [ouj@qiuworld.com Python-2.7.2]$ make [ouj@qiuworld.com Python-2.7.2]$ sudo make install [ouj@qiuworld.com Python-2.7.2]$ sudo ln -s /opt/python2.7/bin/python /usr/bin/python2.7 [ouj@qiuworld.com Python-2.7.2]$ sudo echo '/opt/python2.7/lib'>> /etc/ld.so.conf.d/opt-python2.7.conf [ouj@qiuworld.com Python-2.7.2]$ sudo /sbin/ldconfig [ouj@qiuworld.com Python-2.7.2]$ python2.7 Python 2.7.2 (default, Nov 14 2011, 17:02:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "", line 1, in ImportError: No module named numpy
如果不新建/etc/ld.so.conf.d/opt-python2.7.conf文件并在当中写入一行/opt/python2.7/lib,将会得到如下错误:
[ouj@qiuworld.com Python-2.7.2]$ python2.7 /usr/bin/python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory [ouj@qiuworld.com Python-2.7.2]$ ldd python2.7 linux-vdso.so.1 => (0x00007fff475fc000) libpython2.7.so.1.0 => not found /lib64/libpthread.so.0 (0x000000349dc00000) libdl.so.2 => /lib64/libdl.so.2 (0x000000349d400000) libutil.so.1 => /lib64/libutil.so.1 (0x00000034a6400000) libm.so.6 => /lib64/libm.so.6 (0x000000349d800000) libc.so.6 => /lib64/libc.so.6 (0x000000349d000000) /lib64/ld-linux-x86-64.so.2 (0x000000349cc00000)
接下来我们安装NumPy。它的安装需要事先安装两个库,ATLAS+LAPACK,我们需要下载并安装它们。
[ouj@qiuworld.com ~]$ wget http://www.netlib.org/lapack/lapack-3.3.1.tgz [ouj@qiuworld.com ~]$ tar zxvf lapack-3.3.1.tgz [ouj@qiuworld.com ~]$ cd lapack-3.3.1 [ouj@qiuworld.com lapack-3.3.1]$ cp INSTALL/make.inc.gfortran make.inc [ouj@qiuworld.com lapack-3.3.1]$ vi make.inc #修改OPTS及NOOPT两行 ... OPTS = -O2 -fPIC ... NOOPT = -O0 -fPIC ... [ouj@qiuworld.com lapack-3.3.1]$ cd SRC [ouj@qiuworld.com SRC]$ make [ouj@qiuworld.com SRC]$ cd .. [ouj@qiuworld.com lapack-3.3.1]$ sudo cp lapack_LINUX.a /usr/local/lib/ [ouj@qiuworld.com ~]$ #去http://sourceforge.net/project/showfiles.php?group_id=23725 下载ATLAS库 [ouj@qiuworld.com ~]$ tar jxvf atlas3.8.4.tar.bz2 [ouj@qiuworld.com ~]$ cd ATLAS/ [ouj@qiuworld.com ATLAS]$ mkdir ATLAS_x86_64 [ouj@qiuworld.com ATLAS]$ cd ATLAS_x86_64/ [ouj@qiuworld.com ATLAS_x86_64]$ ../configure -Fa alg -fPIC --with-netlib-lapack=/usr/local/lib/lapack_LINUX.a [ouj@qiuworld.com ATLAS_x86_64]$ make [ouj@qiuworld.com ATLAS_x86_64]$ cd lib [ouj@qiuworld.com lib]$ make shared [ouj@qiuworld.com lib]$ make ptshared [ouj@qiuworld.com lib]$ cd .. [ouj@qiuworld.com ATLAS_x86_64]$ sudo make install [ouj@qiuworld.com ATLAS_x86_64]$ sudo cp lib/*.so /usr/local/atlas/lib/ #手动将所有的动态链接库拷贝至目标目录
安装好了以上两个库之后,接下来的任务就是下载安装numpy和scipy了。
[ouj@qiuworld.com ~]$ sudo ln -s /usr/lib/liblapack.so.3.0.3 /usr/lib/liblapack.so [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib64/liblapack.so.3.0.3 /usr/lib64/liblapack.so [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib/libblas.so.3.0.3 /usr/lib/libblas.so [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib64/libblas.so.3.0.3 /usr/lib64/libblas.so [ouj@qiuworld.com ~]$ cd numpy-1.6.1 [ouj@qiuworld.com numpy-1.6.1]$ export BLAS=/usr/lib64/libblas.so [ouj@qiuworld.com numpy-1.6.1]$ export LAPACK=/usr/lib64/liblapack.so [ouj@qiuworld.com numpy-1.6.1]$ export ATLAS=/usr/local/atlas/lib/libatlas.so [ouj@qiuworld.com numpy-1.6.1]$ /opt/python2.7/bin/python2.7 setup.py clean [ouj@qiuworld.com numpy-1.6.1]$ /opt/python2.7/bin/python2.7 setup.py build [ouj@qiuworld.com numpy-1.6.1]$ sudo /opt/python2.7/bin/python2.7 setup.py install --prefix=/opt/python2.7 [ouj@qiuworld.com numpy-1.6.1]$ /opt/python2.7/bin/python Python 2.7.2 (default, Nov 14 2011, 17:02:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "", line 1, in File "numpy/__init__.py", line 127, in raise ImportError(msg) ImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python intepreter from there. >>> #上面这个错误表明不能在安装目录调用numpy包 [ouj@qiuworld.com numpy-1.6.1]$ cd .. [ouj@qiuworld.com ~]$ /opt/python2.7/bin/python Python 2.7.2 (default, Nov 14 2011, 17:02:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import numpy Traceback (most recent call last): File "", line 1, in File "/opt/python2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in import add_newdocs File "/opt/python2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in from numpy.lib import add_newdoc File "/opt/python2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 13, in from polynomial import * File "/opt/python2.7/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 17, in from numpy.linalg import eigvals, lstsq File "/opt/python2.7/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 48, in from linalg import * File "/opt/python2.7/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 23, in from numpy.linalg import lapack_lite ImportError: libptf77blas.so: cannot open shared object file: No such file or directory >>> #这个错误说找不到libptf77blas.so,但实际上我是安装过它的。 [ouj@qiuworld.com ~]$ ldd /opt/python2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so linux-vdso.so.1 => (0x00007fffed31e000) liblapack.so => /usr/lib64/liblapack.so (0x00002abad6b03000) libptf77blas.so => not found not found not found /opt/python2.7/lib/libpython2.7.so.1.0 (0x00002abad720d000) libgfortran.so.1 => /usr/lib64/libgfortran.so.1 (0x00002abad75d8000) libm.so.6 => /lib64/libm.so.6 (0x00002abad786f000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002abad7af2000) libc.so.6 => /lib64/libc.so.6 (0x00002abad7d01000) libblas.so.3 => /usr/lib64/libblas.so.3 (0x00002abad8059000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00002abad82ae000) libdl.so.2 => /lib64/libdl.so.2 (0x00002abad84ca000) libutil.so.1 => /lib64/libutil.so.1 (0x00002abad86ce000) /lib64/ld-linux-x86-64.so.2 (0x000000349cc00000) [ouj@qiuworld.com ATLAS_x86_64]$ LD_LIBRARY_PATH=/usr/local/atlas/lib:$LD_LIBRARY_PATH ldd /opt/python2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so linux-vdso.so.1 => (0x00007fff0b5fc000) liblapack.so => /usr/local/atlas/lib/liblapack.so (0x00002ae8c1585000) libptf77blas.so => /usr/local/atlas/lib/libptf77blas.so (0x00002ae8c1da1000) libptcblas.so => /usr/local/atlas/lib/libptcblas.so (0x00002ae8c1fbd000) libatlas.so => /usr/local/atlas/lib/libatlas.so (0x00002ae8c21db000) libpython2.7.so.1.0 => /opt/python2.7/lib/libpython2.7.so.1.0 (0x00002ae8c2d0d000) libgfortran.so.1 => /usr/lib64/libgfortran.so.1 (0x00002ae8c30d7000) libm.so.6 => /lib64/libm.so.6 (0x00002ae8c336e000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002ae8c35f2000) libc.so.6 => /lib64/libc.so.6 (0x00002ae8c3800000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ae8c3b58000) libdl.so.2 => /lib64/libdl.so.2 (0x00002ae8c3d74000) libutil.so.1 => /lib64/libutil.so.1 (0x00002ae8c3f78000) /lib64/ld-linux-x86-64.so.2 (0x000000349cc00000) [ouj@qiuworld.com ATLAS_x86_64]$ sudo vi /etc/ld.so.conf.d/python27.conf /opt/python2.7/lib/ /usr/local/atlas/lib/ #再加入这一行,让它能找到libptf77blas.so等。 [ouj@qiuworld.com ATLAS_x86_64]$ sudo /sbin/ldconfig [ouj@qiuworld.com ~]$ cd scipy-0.10.0 [ouj@qiuworld.com scipy-0.10.0]$ /opt/python2.7/bin/python setup.py build [ouj@qiuworld.com scipy-0.10.0]$ sudo /opt/python2.7/bin/python setup.py install [ouj@qiuworld.com ~]$ python2.7 Python 2.7.2 (default, Nov 14 2011, 17:02:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import scipy >>> import numpy >>>
接下来开始正式安装HTSeq.
[ouj@qiuworld.com ~]$ cd HTSeq-0.5.3p3 [ouj@qiuworld.com HTSeq-0.5.3p3]$ sudo /opt/python2.7/bin/python setup.py build [ouj@qiuworld.com HTSeq-0.5.3p3]$ sudo /opt/python2.7/bin/python setup.py install [ouj@qiuworld.com HTSeq-0.5.3p3]$ cd .. [ouj@qiuworld.com ~]$ python2.7 Python 2.7.2 (default, Nov 14 2011, 17:02:46) [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import HTSeq >>>
原文来自:http://blog.qiubio.com:8080/archives/2549