7

I try install rpy2 but I have this error below.

I read in the web that the problem it's the Environment Variables but I have C:\Rtools\bin and C:\Program Files\R\R-3.2.2\bin in System Variable Path.

what am I doing wrong?

Error:

C:\Users\rmalveslocal>pip install rpy2
Collecting rpy2

  Downloading rpy2-2.7.6.tar.gz (177kB)
    100% |################################| 180kB 1.3MB/s

    Complete output from command python setup.py egg_info:
    R version 3.2.2 (2015-08-14) -- "Fire Safety"
    Copyright (C) 2015 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/.

    'sh' is not recognized as an internal or external command,
    operable program or batch file.
    R version 3.2.2 (2015-08-14) -- "Fire Safety"
    C:\PROGRA~1\R\R-32~1.2\bin\x64\R CMD config --ldflags
    Traceback (most recent call last):
      File "<string>", line 20, in <module>

      File "c:\users\rmalve~1\appdata\local\temp\2\pip-build-vvy8sl\rpy2\setup.p
y", line 291, in <module>
        ri_ext = getRinterface_ext()
      File "c:\users\rmalve~1\appdata\local\temp\2\pip-build-vvy8sl\rpy2\setup.p
y", line 198, in getRinterface_ext
        ldf = shlex.split(' '.join(rexec.cmd_config('--ldflags')))
      File "c:\users\rmalve~1\appdata\local\temp\2\pip-build-vvy8sl\rpy2\setup.p
y", line 151, in cmd_config
        universal_newlines = True)
      File "C:\Users\rmalveslocal\Anaconda\lib\subprocess.py", line 573, in chec
k_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '('C:\\PROGRA~1\\R\\R-32~1.2\\bin\\x6
4\\R', 'CMD', 'config', '--ldflags')' returned non-zero exit status 1

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\rmalve~1
\appdata\local\temp\2\pip-build-vvy8sl\rpy2
Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501
Kardu
  • 865
  • 3
  • 13
  • 24
  • I tried to install it for 2 days with no luck. gl – Pierre L Dec 29 '15 at 14:23
  • What version of python? – Kyle Pittman Dec 29 '15 at 14:25
  • @Monkpit Python 2.7.11 |Anaconda 2.4.1 (64-bit) – Kardu Dec 29 '15 at 14:26
  • In the rpy2 docs: `rpy2 is most likely not working with Python 2.6. Older Python like 2.5 or even 2.4 might compile, but there is much less testing done with those platforms, if any, and likely limited hope for free support. While Python 3.3 is supported, earlier version of Python 3 are not (they might work, they might not - you are on your own).` http://rpy2.readthedocs.org/en/version_2.7.x/overview.html#installation – Kyle Pittman Dec 29 '15 at 14:30
  • Possible duplicate of [http://stackoverflow.com/questions/14882477/rpy2-install-on-windows-7](http://stackoverflow.com/questions/14882477/rpy2-install-on-windows-7) – Yubin Lee Dec 29 '15 at 14:48
  • Are you running this from cygwin? – Padraic Cunningham Dec 29 '15 at 15:20
  • @PierreLafortune Although there is no real support of rpy2 on Windows Kardu got an answer about an hour after posting here. Share what did not work for you: at the very minimum it will help identify install issues occurring the most. – lgautier Dec 30 '15 at 04:04
  • @PierreLafortune I followed what Konstantinos Evangelidis told, and worked in python 2.7 and 3.5 – Kardu Dec 30 '15 at 09:15
  • @YubinLee different error message – Franck Dernoncourt Jul 20 '17 at 17:11

2 Answers2

8
  1. Download the version you need here http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2
  2. Open Anaconda Prompt and navigate to the folder you have downloaded the file
  3. Run pip install file_name.whl
0

To solve:

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

You need to add sh.exe to your path. Some programs such as GitHub Desktop (e.g., C:\Users\bob\AppData\Local\GitHubDesktop\app-0.7.0\resources\app\git\usr\bin) or Cygwin come with sh.exe.

I recommend http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2 + e.g. pip install rpy2-2.8.6-cp36-cp36m-win_amd64.whl as Konstantinos Evangelidis mentioned, it makes life much easier.

Your next step might be: Rpy2 error wac-a-mole: R_USER not defined

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501