【发布时间】:2014-07-17 17:07:27
【问题描述】:
我正在尝试使用 IPython 笔记本的 rmagic 扩展,通过 Enthought Canopy 使用 Python 2.7.6。
当我尝试以下示例时:
import numpy as np
import pylab
X = np.array([0,1,2,3,4])
Y = np.array([3,5,4,6,7])
pylab.scatter(X, Y)
%Rpush X Y
%R lm(Y~X)$coef
我收到一个错误:
AttributeError Traceback (most recent call last)
<ipython-input-7-96dff2c70ba0> in <module>()
1 get_ipython().magic(u'Rpush X Y')
----> 2 get_ipython().magic(u'R lm(Y~X)$coef')
…
/Users/hrob/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/extensions/rmagic.pyc in eval(self, line)
212 res = ro.r("withVisible({%s})" % line)
213 value = res[0] #value (R object)
--> 214 visible = ro.conversion.ri2py(res[1])[0] #visible (boolean)
215 except (ri.RRuntimeError, ValueError) as exception:
216 warning_or_other_msg = self.flush() # otherwise next return seems to have copy of error
AttributeError: 'module' object has no attribute 'ri2py'
我找不到其他人遇到过同样的问题,但我自己也没有足够的知识来解决它。但是,conversion.py 中没有 ri2py 的定义。
我最初安装了 Anaconda 并通过它运行 python notebook,结果完全相同。
rpy2(2.4.0 版)安装成功,但是当我测试它时,我得到 1 个预期失败,如下所示:
python -m 'rpy2.robjects.tests.__init__'
…
testNewWithTranslation (testFunction.SignatureTranslatedFunctionTestCase) ... expected failure
我不知道这是否相关。
谁能提出问题可能是什么以及我可以如何解决它?我使用的 python、R 等版本是否兼容,或者我需要重新安装/更新一些东西吗?
【问题讨论】: