在centOS 5上安装HTSeq

安装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.

  1. [ouj@qiuworld.com ~]$ tar -xzvf Python-2.7.2.tgz
  2. [ouj@qiuworld.com ~]$ cd Python-2.7.2
  3. [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tcl #需要安装tcl/tk库
  4. [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tcl-devel
  5. [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tk
  6. [ouj@qiuworld.com Python-2.7.2]$ sudo yum install tk-devel
  7. [ouj@qiuworld.com Python-2.7.2]$ ./configure --prefix=/opt/python2.7 --with-threads --enable-shared
  8. [ouj@qiuworld.com Python-2.7.2]$ make
  9. [ouj@qiuworld.com Python-2.7.2]$ sudo make install
  10. [ouj@qiuworld.com Python-2.7.2]$ sudo ln -s /opt/python2.7/bin/python /usr/bin/python2.7
  11. [ouj@qiuworld.com Python-2.7.2]$ sudo echo '/opt/python2.7/lib'>> /etc/ld.so.conf.d/opt-python2.7.conf
  12. [ouj@qiuworld.com Python-2.7.2]$ sudo /sbin/ldconfig
  13. [ouj@qiuworld.com Python-2.7.2]$ python2.7
  14. Python 2.7.2 (default, Nov 14 2011, 17:02:46)
  15. [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
  16. Type "help", "copyright", "credits" or "license" for more information.
  17. >>> import numpy
  18. Traceback (most recent call last):
  19. File "", line 1, in
  20. ImportError: No module named numpy

如果不新建/etc/ld.so.conf.d/opt-python2.7.conf文件并在当中写入一行/opt/python2.7/lib,将会得到如下错误:

  1. [ouj@qiuworld.com Python-2.7.2]$ python2.7
  2. /usr/bin/python2.7: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
  3. [ouj@qiuworld.com Python-2.7.2]$ ldd python2.7
  4. linux-vdso.so.1 => (0x00007fff475fc000)
  5. libpython2.7.so.1.0 => not found /lib64/libpthread.so.0 (0x000000349dc00000)
  6. libdl.so.2 => /lib64/libdl.so.2 (0x000000349d400000)
  7. libutil.so.1 => /lib64/libutil.so.1 (0x00000034a6400000)
  8. libm.so.6 => /lib64/libm.so.6 (0x000000349d800000)
  9. libc.so.6 => /lib64/libc.so.6 (0x000000349d000000)
  10. /lib64/ld-linux-x86-64.so.2 (0x000000349cc00000)

接下来我们安装NumPy。它的安装需要事先安装两个库,ATLAS+LAPACK,我们需要下载并安装它们。

  1. [ouj@qiuworld.com ~]$ wget http://www.netlib.org/lapack/lapack-3.3.1.tgz
  2. [ouj@qiuworld.com ~]$ tar zxvf lapack-3.3.1.tgz
  3. [ouj@qiuworld.com ~]$ cd lapack-3.3.1
  4. [ouj@qiuworld.com lapack-3.3.1]$ cp INSTALL/make.inc.gfortran make.inc
  5. [ouj@qiuworld.com lapack-3.3.1]$ vi make.inc
  6. #修改OPTS及NOOPT两行
  7. ...
  8. OPTS = -O2 -fPIC
  9. ...
  10. NOOPT = -O0 -fPIC
  11. ...
  12. [ouj@qiuworld.com lapack-3.3.1]$ cd SRC
  13. [ouj@qiuworld.com SRC]$ make
  14. [ouj@qiuworld.com SRC]$ cd ..
  15. [ouj@qiuworld.com lapack-3.3.1]$ sudo cp lapack_LINUX.a /usr/local/lib/
  16. [ouj@qiuworld.com ~]$ #去http://sourceforge.net/project/showfiles.php?group_id=23725 下载ATLAS库
  17. [ouj@qiuworld.com ~]$ tar jxvf atlas3.8.4.tar.bz2
  18. [ouj@qiuworld.com ~]$ cd ATLAS/
  19. [ouj@qiuworld.com ATLAS]$ mkdir ATLAS_x86_64
  20. [ouj@qiuworld.com ATLAS]$ cd ATLAS_x86_64/
  21. [ouj@qiuworld.com ATLAS_x86_64]$ ../configure -Fa alg -fPIC --with-netlib-lapack=/usr/local/lib/lapack_LINUX.a
  22. [ouj@qiuworld.com ATLAS_x86_64]$ make
  23. [ouj@qiuworld.com ATLAS_x86_64]$ cd lib
  24. [ouj@qiuworld.com lib]$ make shared
  25. [ouj@qiuworld.com lib]$ make ptshared
  26. [ouj@qiuworld.com lib]$ cd ..
  27. [ouj@qiuworld.com ATLAS_x86_64]$ sudo make install
  28. [ouj@qiuworld.com ATLAS_x86_64]$ sudo cp lib/*.so /usr/local/atlas/lib/ #手动将所有的动态链接库拷贝至目标目录

安装好了以上两个库之后,接下来的任务就是下载安装numpy和scipy了。

  1. [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib/liblapack.so.3.0.3 /usr/lib/liblapack.so
  2. [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib64/liblapack.so.3.0.3 /usr/lib64/liblapack.so
  3. [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib/libblas.so.3.0.3 /usr/lib/libblas.so
  4. [ouj@qiuworld.com ~]$ sudo ln -s /usr/lib64/libblas.so.3.0.3 /usr/lib64/libblas.so
  5. [ouj@qiuworld.com ~]$ cd numpy-1.6.1
  6. [ouj@qiuworld.com numpy-1.6.1]$ export BLAS=/usr/lib64/libblas.so
  7. [ouj@qiuworld.com numpy-1.6.1]$ export LAPACK=/usr/lib64/liblapack.so
  8. [ouj@qiuworld.com numpy-1.6.1]$ export ATLAS=/usr/local/atlas/lib/libatlas.so
  9. [ouj@qiuworld.com numpy-1.6.1]$ /opt/python2.7/bin/python2.7 setup.py clean
  10. [ouj@qiuworld.com numpy-1.6.1]$ /opt/python2.7/bin/python2.7 setup.py build
  11. [ouj@qiuworld.com numpy-1.6.1]$ sudo /opt/python2.7/bin/python2.7 setup.py install --prefix=/opt/python2.7
  12. [ouj@qiuworld.com numpy-1.6.1]$ /opt/python2.7/bin/python
  13. Python 2.7.2 (default, Nov 14 2011, 17:02:46)
  14. [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
  15. Type "help", "copyright", "credits" or "license" for more information.
  16. >>> import numpy
  17. Traceback (most recent call last):
  18. File "", line 1, in
  19. File "numpy/__init__.py", line 127, in
  20. raise ImportError(msg)
  21. ImportError: Error importing numpy: you should not try to import numpy from
  22. its source directory; please exit the numpy source tree, and relaunch
  23. your python intepreter from there.
  24. >>> #上面这个错误表明不能在安装目录调用numpy包
  25. [ouj@qiuworld.com numpy-1.6.1]$ cd ..
  26. [ouj@qiuworld.com ~]$ /opt/python2.7/bin/python
  27. Python 2.7.2 (default, Nov 14 2011, 17:02:46)
  28. [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
  29. Type "help", "copyright", "credits" or "license" for more information.
  30. >>> import numpy
  31. Traceback (most recent call last):
  32. File "", line 1, in
  33. File "/opt/python2.7/lib/python2.7/site-packages/numpy/__init__.py", line 137, in
  34. import add_newdocs
  35. File "/opt/python2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in
  36. from numpy.lib import add_newdoc
  37. File "/opt/python2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 13, in
  38. from polynomial import *
  39. File "/opt/python2.7/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 17, in
  40. from numpy.linalg import eigvals, lstsq
  41. File "/opt/python2.7/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 48, in
  42. from linalg import *
  43. File "/opt/python2.7/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 23, in
  44. from numpy.linalg import lapack_lite
  45. ImportError: libptf77blas.so: cannot open shared object file: No such file or directory
  46. >>> #这个错误说找不到libptf77blas.so,但实际上我是安装过它的。
  47. [ouj@qiuworld.com ~]$ ldd /opt/python2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so
  48. linux-vdso.so.1 => (0x00007fffed31e000)
  49. liblapack.so => /usr/lib64/liblapack.so (0x00002abad6b03000)
  50. libptf77blas.so => not found not found not found /opt/python2.7/lib/libpython2.7.so.1.0 (0x00002abad720d000)
  51. libgfortran.so.1 => /usr/lib64/libgfortran.so.1 (0x00002abad75d8000)
  52. libm.so.6 => /lib64/libm.so.6 (0x00002abad786f000)
  53. libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002abad7af2000)
  54. libc.so.6 => /lib64/libc.so.6 (0x00002abad7d01000)
  55. libblas.so.3 => /usr/lib64/libblas.so.3 (0x00002abad8059000)
  56. libpthread.so.0 => /lib64/libpthread.so.0 (0x00002abad82ae000)
  57. libdl.so.2 => /lib64/libdl.so.2 (0x00002abad84ca000)
  58. libutil.so.1 => /lib64/libutil.so.1 (0x00002abad86ce000)
  59. /lib64/ld-linux-x86-64.so.2 (0x000000349cc00000)
  60. [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
  61. linux-vdso.so.1 => (0x00007fff0b5fc000)
  62. liblapack.so => /usr/local/atlas/lib/liblapack.so (0x00002ae8c1585000)
  63. libptf77blas.so => /usr/local/atlas/lib/libptf77blas.so (0x00002ae8c1da1000)
  64. libptcblas.so => /usr/local/atlas/lib/libptcblas.so (0x00002ae8c1fbd000)
  65. libatlas.so => /usr/local/atlas/lib/libatlas.so (0x00002ae8c21db000)
  66. libpython2.7.so.1.0 => /opt/python2.7/lib/libpython2.7.so.1.0 (0x00002ae8c2d0d000)
  67. libgfortran.so.1 => /usr/lib64/libgfortran.so.1 (0x00002ae8c30d7000)
  68. libm.so.6 => /lib64/libm.so.6 (0x00002ae8c336e000)
  69. libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002ae8c35f2000)
  70. libc.so.6 => /lib64/libc.so.6 (0x00002ae8c3800000)
  71. libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ae8c3b58000)
  72. libdl.so.2 => /lib64/libdl.so.2 (0x00002ae8c3d74000)
  73. libutil.so.1 => /lib64/libutil.so.1 (0x00002ae8c3f78000)
  74. /lib64/ld-linux-x86-64.so.2 (0x000000349cc00000)
  75. [ouj@qiuworld.com ATLAS_x86_64]$ sudo vi /etc/ld.so.conf.d/python27.conf
  76. /opt/python2.7/lib/
  77. /usr/local/atlas/lib/ #再加入这一行,让它能找到libptf77blas.so等。
  78. [ouj@qiuworld.com ATLAS_x86_64]$ sudo /sbin/ldconfig
  79. [ouj@qiuworld.com ~]$ cd scipy-0.10.0
  80. [ouj@qiuworld.com scipy-0.10.0]$ /opt/python2.7/bin/python setup.py build
  81. [ouj@qiuworld.com scipy-0.10.0]$ sudo /opt/python2.7/bin/python setup.py install
  82. [ouj@qiuworld.com ~]$ python2.7
  83. Python 2.7.2 (default, Nov 14 2011, 17:02:46)
  84. [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
  85. Type "help", "copyright", "credits" or "license" for more information.
  86. >>> import scipy
  87. >>> import numpy
  88. >>>

接下来开始正式安装HTSeq.

  1. [ouj@qiuworld.com ~]$ cd HTSeq-0.5.3p3
  2. [ouj@qiuworld.com HTSeq-0.5.3p3]$ sudo /opt/python2.7/bin/python setup.py build
  3. [ouj@qiuworld.com HTSeq-0.5.3p3]$ sudo /opt/python2.7/bin/python setup.py install
  4. [ouj@qiuworld.com HTSeq-0.5.3p3]$ cd ..
  5. [ouj@qiuworld.com ~]$ python2.7
  6. Python 2.7.2 (default, Nov 14 2011, 17:02:46)
  7. [GCC 4.1.2 20080704 (Red Hat 4.1.2-51)] on linux2
  8. Type "help", "copyright", "credits" or "license" for more information.
  9. >>> import HTSeq
  10. >>>

原文来自:http://blog.qiubio.com:8080/archives/2549

 

发表评论

匿名网友

拖动滑块以完成验证
加载失败