Linux下源码编译安装rpy2
时间:2015-10-21 18:55:55
收藏:0
阅读:1149
R(又称R语言)是一款开源的跨平台的数值统计和数值图形化展现工具。rpy2是Python直接调用R的第三方库,它可以实现使用python读取R的对象、调用R的方法以及Python与R数据结构转换等。这里主要介绍一下在没有网络的情况下,源码安装rpy2的一些方法,以作备忘。
1、python安装
$ wget https://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
$ tar zvxf Python-2.7.6.tgz
$ cd Python-2.7.6
$ ./configure --prefix=/ifs1/NGB_DB/shenweiyan/LocalSoft/Tools/Python-2.7.6
$ make && make install
$ tar zvxf Python-2.7.6.tgz
$ cd Python-2.7.6
$ ./configure --prefix=/ifs1/NGB_DB/shenweiyan/LocalSoft/Tools/Python-2.7.6
$ make && make install
python安装完需要设置用户环境变量~/.bashrc,以指定Python所在路径:(此后的相关包安装都将会自动安装在该环境变量所指向的site-packages下,无需另行指定。)
export PATH="/ifs1/NGB_DB/shenweiyan/LocalSoft/Tools/Python-2.7.6/bin:$PATH
2、setuptools安装
setuptools是python包管理工具,它可以帮助我们更简单地创建和分发python包,尤其是拥有依赖关系的。我们需要安装第三方python包时,可能会用到easy_installl命令。easy_install是由PEAK(Python Enterprise Application Kit)开发的setuptools包里带的一个命令,所以使用easy_install实际上是在调用setuptools来完成安装模块的工作。
=> wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.4.tar.gz#md5=214c6c43bd7035e870c1beab402c48e7 --no-check-certificate
=> tar zvxf setuptools-18.4.tar.gz
=> cd setuptools-18.4
=> python setup.py install (easy_install默认安装在环境变量所指定的python路径下:/ifs1/NGB_DB/shenweiyan/LocalSoft/Tools/Python-2.7.6/bin)
=> tar zvxf setuptools-18.4.tar.gz
=> cd setuptools-18.4
=> python setup.py install (easy_install默认安装在环境变量所指定的python路径下:/ifs1/NGB_DB/shenweiyan/LocalSoft/Tools/Python-2.7.6/bin)
3、安装rpy2依赖包
rpy2包的安装依赖于singledispatch包的安装,而singledispatch包又依赖于six包。
=> wget https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55 --no-check-certificate
=> cd six-1.10.0
=> python setup.py install
=> wget https://pypi.python.org/packages/source/s/singledispatch/singledispatch-3.4.0.3.tar.gz#md5=af2fc6a3d6cc5a02d0bf54d909785fcb --no-check-certificate
=> tar zvxf singledispatch-3.4.0.3.tar.gz
=> cd singledispatch-3.4.0.3
=> python setup.py install
=> cd six-1.10.0
=> python setup.py install
=> wget https://pypi.python.org/packages/source/s/singledispatch/singledispatch-3.4.0.3.tar.gz#md5=af2fc6a3d6cc5a02d0bf54d909785fcb --no-check-certificate
=> tar zvxf singledispatch-3.4.0.3.tar.gz
=> cd singledispatch-3.4.0.3
=> python setup.py install
4、 R安装
Linux下R的源码编译安装,这里不详细介绍,详细安装信息参考《Linux下R编译安装》。
rpy2的安装需要指定R软件所在路径,否则将会出现以下错误:Error: Tried to guess R‘s HOME but no command (R) in the PATH.
export PATH="/ifs1/NGB_DB/shenweiyan/LocalSoft/Tools/R-3.1.2/bin:$PATH"
5、rpy2安装
=> wget https://pypi.python.org/packages/source/r/rpy2/rpy2-2.7.2.tar.gz --no-check-certificate
=> tar zvxf rpy2-2.7.2.tar.gz
=> cd rpy2-2.7.2
=> python setup.py install
=> tar zvxf rpy2-2.7.2.tar.gz
=> cd rpy2-2.7.2
=> python setup.py install
如下所示,rpy2安装成功:
ok,问题解决!!!
评论(0)