以下工作在RHEL6上,它仍在运行Python 2.6。为了让rpy2安装脚本找到R,我们需要从Python 2.7复制一些代码到rpy2的安装文件中。
运行
pip install rpy2
其未能按你的描述后,输出告诉我们到哪里寻找下载的代码(例如/ tmp目录/ PIP-集结meuser/rpy2 /)
访问该文件夹,编辑setup.py 第一个“高清”行前添加以下代码:
import subprocess
if "check_output" not in dir(subprocess): # duck punch it in!
def f(*popenargs, **kwargs):
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
cmd = kwargs.get("args")
if cmd is None:
cmd = popenargs[0]
raise subprocess.CalledProcessError(retcode, cmd)
return output
subprocess.check_output = f
保存文件。现在再次尝试你的pip安装行;它应该工作。
以供参考,该源从https://hg.python.org/cpython/file/d37f963394aa/Lib/subprocess.py#l544 来了,解决的办法是从一个类似的问题,subprocess.check_output() doesn't seem to exist (Python 2.6.5)
如果你碰巧没有root访问的服务器上运行,则可能反而可以使用安装命令
pip install --upgrade -v --user rpy2
将最新的rpy2安装到您的本地(用户)帐户中。其他一切都是一样的。
我有同样的问题,并希望以应用解决方案。但是,在错误行中报告的那个目录在创建后立即被删除。任何方法来克服这一点? – splinter
对不起。我从RHEL转移了。其他人可以帮忙吗?尽管Ctrl-z会中断/暂停点进程...(键入“fg”来恢复它) – CPBL