Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

python - Installing rpy2 on windows

I am trying to install rpy2 on a machine running Windows 10. I have already installed R 3.4.4 (64bit) and it works fine in RGui. I then tried to pip install rpy2, but was getting an error that it couldn't find R, so I added c:Program FilesRR-3.4.4in to my path environment variable. Now when I do

pip install rpy2

I get a different error:

Command '('c:PROGRA~1RR-34~1.4inx64R', 'CMD', 'config', '--ldflags')' returned non-zero exit status 1

The full output is given below. Any idea what I am doing wrong?


pip install rpy2

Collecting rpy2
  Downloading https://files.pythonhosted.org/packages/88/f7/788e5e1587bc1ab48b5b0467f9c3a08ef5aadbd993ed835559a10e452121/rpy2-2.9.3.tar.gz (193kB)
Complete output from command python setup.py egg_info:
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 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.4.4 (2018-03-15) -- "Someone to Lean On"
c:PROGRA~1RR-34~1.4inx64R CMD config --ldflags
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:UserspyAppDataLocalTemppip-build-qz4rb_4o
py2setup.py", line 374, in <module>
    ri_ext = getRinterface_ext()
  File "C:UserspyAppDataLocalTemppip-build-qz4rb_4o
py2setup.py", line 269, in getRinterface_ext
    ldf = shlex.split(' '.join(rexec.cmd_config('--ldflags')))
  File "C:UserspyAppDataLocalTemppip-build-qz4rb_4o
py2setup.py", line 222, in cmd_config
    universal_newlines = True)
  File "c:userspyminiconda3libsubprocess.py", line 626, in check_output
    **kwargs).stdout
  File "c:userspyminiconda3libsubprocess.py", line 708, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '('c:\PROGRA~1\R\R-34~1.4\bin\x64\R', 'CMD', 'config', '--ldflags')' returned non-zero exit status 1

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:UserspyAppDataLocalTemppip-build-qz4rb_4o
py2
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The output contains the error:

'sh' is not recognized as an internal or external command

but I thought it was only a warning (as there was output coming after it). sh (shell) is Nix specific and (naturally) doesn't exist on Win. However, if you install a port for Win, or an Lnx env emulator (like Cygwin), it might work.

Here's what [ReadTheDocs.rpy2]: Installation (which has "Compiling on Linux" and "Compiling on OS X" sections, but nothing about Win, although it mentions that it should compile successfully) states:

  • There is currently no binaries or support for Microsoft Windows (more for lack of resources than anything else).

  • Microsoft’s Windows - unofficial and unsupported binaries are provided by Christoph Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs); there is otherwise currently close to no support for this platform



Update #0

Adding steps that @pyguy took (from comment), in order to successfully install rpy2:

  • Download rpy2?2.9.3?cp35?cp35m?win_amd64.whl (or any newer version that might have been added in the meantime) from [UCI.LFD]: Unofficial Windows Binaries for Python Extension Packages (for 32bit, download the *win32.whl)
  • Open a cmd window (as Administrator) in the .whl's download dir
  • Set R_USER env var to current username: set R_USER=%USERNAME%
  • python -m pip install rpy2?2.9.3?cp35?cp35m?win_amd64.whl (Python's (binary) dir must be in %PATH%, or specify the full path)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...