IPython笔记本和rmagic / rpy2:找不到模块ri2py(OSX 10.8.5,python 2.7,R 3.1) [英] IPython notebook and rmagic/rpy2: cannot find module ri2py (OSX 10.8.5, python 2.7, R 3.1)

查看:144
本文介绍了IPython笔记本和rmagic / rpy2:找不到模块ri2py(OSX 10.8.5,python 2.7,R 3.1)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用IPython笔记本的rmagic扩展,使用Python 2.7.6通过Enthought Canopy。

I'm trying to use the rmagic extension for the IPython notebook, using Python 2.7.6 via Enthought Canopy.

当我尝试以下示例时:

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笔记本,结果完全相同。

I can't find anyone else who's had the same problem and don't know enough to solve it myself. There is no definition for ri2py in conversion.py though.
I initially had installed Anaconda and was running python notebook through that, with exactly the same results.

rpy2(版本2.4.0)安装成功,但是当我测试它时,我得到1个预期失败,如下所示:

rpy2 (version 2.4.0) installed successfully but when I test it I get 1 expected failure as follows:

python -m 'rpy2.robjects.tests.__init__'  
…  
testNewWithTranslation (testFunction.SignatureTranslatedFunctionTestCase) ... expected failure

我不知道这是否相关。

有人可以提出问题可能是什么以及我如何解决它?我正在使用兼容的python,R等版本,还是需要重新安装/更新某些东西?

Can anyone suggest what the problem might be and how I might fix it? Are the versions of python, R, etc. that I'm using compatible or do I need to re-install/update something?

推荐答案

您使用%load_ext rmagic

如果是,请尝试使用% load_ext rpy2.ipython 而不是。

If so, try using %load_ext rpy2.ipython instead.

这是新功能

这篇关于IPython笔记本和rmagic / rpy2:找不到模块ri2py(OSX 10.8.5,python 2.7,R 3.1)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆