I get an error when trying to import rpy2. Here is the code and the error.
>>> 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'
What could be the problem? I am using python version 3.3.3 and pandas version 0.13.1
EDIT
I tried installing rpy2 separately.
Direct use python setup.py installgave me an error that osdoes not have a module popen3.
Directly installing exe (rpy2-2.3.9.win32-py3.3.exe) from the Christoph Gohlke website http://www.lfd.uci.edu/~gohlke/pythonlibs/ works fine. But if I try to do import pandas.rpy.common as com, then I get the following error (problem loading the DLL in from rpy2.rinterface._rinterface import *:
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.
EDIT
In the end, I decided. It seems that adding environment variables R_HOME and R_USER led to the trick.
source
share