当我尝试导入rpy2时出现错误。这是代码和错误。rpy2导入不起作用
>>> import pandas.rpy.common
Traceback (most recent call last):
File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 2828, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-148-c258a0f70d44>", line 1, in <module>
import pandas.rpy.common
File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\pandas\rpy\common.py", line 14, in <module>
from rpy2.robjects.packages import importr
ImportError: No module named 'rpy2'
可能是什么问题?我使用的Python 3.3.3版和熊猫版本0.13.1
编辑
试过单独安装rpy2。
直接使用
python setup.py install
给了我一个错误,os
没有一个模块popen3
。从Christoph Gohlke的站点http://www.lfd.uci.edu/~gohlke/pythonlibs/直接安装exe(rpy2-2.3.9.win32-py3.3.exe)运行正常。但是,如果我尝试做
import pandas.rpy.common as com
然后我得到以下错误(与加载DLL问题在:Traceback (most recent call last): File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 2828, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "<ipython-input-10-63ebebefea80>", line 1, in <module> import pandas.rpy.common as com File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site- packages\pandas\rpy\common.py", line 14, in <module> from rpy2.robjects.packages import importr File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\rpy2\robjects\__init__.py", line 15, in <module> import rpy2.rinterface as rinterface File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\rpy2\rinterface\__init__.py", line 103, in <module> from rpy2.rinterface._rinterface import * ImportError: DLL load failed: %1 is not a valid Win32 application.
编辑
终于解决了这个问题好像加入R_HOME和R_USER环境变量做到了诀窍:
有关版本信息(例如需要R版本3.2),另请参阅http://askubuntu.com/a/681142/6130 – nealmcb