Error installing rpy2 in windows

I am trying to install the rpy2 package and get the following error as with

C:\python27>easy_install rpy2 Searching for rpy2 Reading http://pypi.python.org/simple/rpy2/ Reading http://rpy.sourceforge.net Best match: rpy2 2.3.3 Downloading http://pypi.python.org/packages/source/r/rpy2/rpy2-2.3.3.tar.gz#md5=6cd95eb70645577cb53198ef0a32395e Processing rpy2-2.3.3.tar.gz Running rpy2-2.3.3\setup.py -q bdist_egg --dist-dir c:\users\chetan~1\appdata\local\temp\easy_install-wfxip9\rpy2-2.3.3\egg-di st-tmp-rrezfb "C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags Invalid substring in string C:\Python27\lib\site-packages\setuptools\command\easy_install.py:921: RuntimeWarning: tp_compare didn't return -1 or -2 for ex ception raise DistutilsError("Setup script exited with %s" % (v.args[0],)) error: Setup script exited with Problem while running `"C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags` 

And when I try pip, this is what I get

 c:\Python27\Lib\site-packages\django\bin>pip install rpy2 

Download / unpack rpy2 Run setup.py egg_info for rpy2 package

 "C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags Invalid substring in string Problem while running `"C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags` 
+8
rpy2
source share
3 answers

I spent a few days on this too ... then I came across this thread where the link is given: http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2

On this page, you can find (among other useful things) a pre-compiled version of rpy2 for Windows and for different versions of Python. It apparently only works for R 2.15.3, I have not tried it with other versions.

+1
source share

Recently I had to try to build it from the source. Got a version of rpy2-2.2.2, so I can use it with Python 2.6.6 on Oracle Linux.

The solution to how this works was to commit a couple of things in a setup.py script.

First enable get_rconfig () to allow empty lines. If there was a way to mark this, this was not obvious to me:

  config = RConfig() for about in ('--ldflags', '--cppflags', 'LAPACK_LIBS', 'BLAS_LIBS'): #config += get_rconfig(r_home, about) config += get_rconfig(r_home, about, allow_empty = True) 

Secondly, fix the error with going to RConfig.from_string, where it referred to a nonexistent variable:

  elif rconfig_m is None: if allow_empty: #if allow_empty and (rconfig == ''): print(cmd + '\nreturned an empty string.\n') 

This then allows the CMD R configuration contours to handle empty cases as well (which you will probably encounter if your R assembly was not created as a shared library), and I can end the loop with

install python setup.py build

0
source share

Mistake

"C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags

probably caused by the lack of tools like unix in windows. (you might also have an error, e.g.

'sh' is not recognized as an internal or external command, operating program, or batch file

Finally, I got it to work with Windows 7 by installing the Rtools and mingw compiler and changing the setup.py and unixccompiler.py files. See rpy2 install on Windows 7

Also a mistake

% load_ext rmagic

RuntimeError ("Cannot find R.dll in% s"% RHOME)

due to the fact that rpy2 could not find R.dll correctly in the code. You can add the R_HOME environment variable, for example, to the C: \ Program Files \ R \ R-3.0.2 folder (for more details see the Link).

Hope this helps.

0
source share

All Articles