Can't install rpy2

Issue #376 closed
Iulia Cioroianu created an issue

I have tried multiple ways of installing rpy2 (pip, from source, from wheel), and multiple versions. Nothing works. Pip and source installation throw this error:

C:\Python27\Lib\site-packages\rpy2\rpy2-rpy2-981d1c6e1260>python setup.py install
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.

R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
C:\R\R-3.3.1\bin\R CMD config --ldflags
'sh' is not recognized as an internal or external command,
operable program or batch file.
Traceback (most recent call last):
  File "setup.py", line 331, in <module>
    ri_ext = getRinterface_ext()
  File "setup.py", line 238, in getRinterface_ext
    ldf = shlex.split(' '.join(rexec.cmd_config('--ldflags')))
  File "setup.py", line 191, in cmd_config
    universal_newlines = True)
  File "C:\Python27\lib\subprocess.py", line 573, in check_output
    raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '('C:\\R\\R-3.3.1\\bin\\R', 'CMD', 'confi
g', '--ldflags')' returned non-zero exit status 1

Installing it from wheel (rpy2-2.7.8-cp27-none-win32.whl) doesn't throw any errors, but the package doesn't work, and this is what I get when I try to import rpy2.robjects:

import rpy2.robjects
Traceback (most recent call last):
  File "<ipython-input-13-bd461266c9bc>", line 1, in <module>
    import rpy2.robjects
  File "C:\Python27\lib\site-packages\rpy2\robjects\__init__.py", line 15, in <module>
    import rpy2.rinterface as rinterface
  File "C:\Python27\lib\site-packages\rpy2\rinterface\__init__.py", line 16, in <module>
    tmp = subprocess.check_output(("R", "RHOME"), universal_newlines=True)
  File "C:\Python27\lib\subprocess.py", line 566, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "C:\Python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

Comments (1)

  1. Laurent Gautier

    You'll need development environment to be able to compile rpy2 from source. If unsure about what this means, you probably don't want to go down that path.

    Christoph Gohlke has been kindly providing unofficial Windows build of rpy2 (http://www.lfd.uci.edu/~gohlke/pythonlibs/) and Continuum seems to have updated its builds of rpy2 (only one minor version behind - https://anaconda.org/r/rpy2 ). You should try to get rpy2 from one of those two places.

    Alternatively, consider using the Docker container.

    I am closing this. Don't hesitate to reopen or comment if needed.

  2. Log in to comment