在 Windows 上安装 rpy2

pyg*_*guy 4 python rpy2

我正在尝试在运行 Windows 10 的计算机上安装 rpy2。我已经安装了 R 3.4.4(64 位)并且它在 RGui 中运行良好。然后我尝试 pip install rpy2,但出现找不到 R 的错误,因此我将 c:\Program Files\R\R-3.4.4\bin\ 添加到我的路径环境变量中。现在当我这样做时

pip install rpy2
Run Code Online (Sandbox Code Playgroud)

我收到一个不同的错误:

命令 '('c:\PROGRA~1\R\R-34~1.4\bin\x64\R', 'CMD', 'config', '--ldflags')' 返回非零退出状态 1

完整的输出如下所示。知道我做错了什么吗?


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~1\R\R-34~1.4\bin\x64\R CMD config --ldflags
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\setup.py", line 374, in <module>
    ri_ext = getRinterface_ext()
  File "C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\setup.py", line 269, in getRinterface_ext
    ldf = shlex.split(' '.join(rexec.cmd_config('--ldflags')))
  File "C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\setup.py", line 222, in cmd_config
    universal_newlines = True)
  File "c:\users\py\miniconda3\lib\subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "c:\users\py\miniconda3\lib\subprocess.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:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\
Run Code Online (Sandbox Code Playgroud)

Cri*_*ati 6

输出包含错误:

\n
\n

\'sh\' 未被识别为内部或外部命令

\n
\n

但我认为这只是一个警告(因为它之后有输出)。
\n sh ( Shell ) 是Nix特定的,并且(自然)在Win上不存在。但是,如果您安装Win端口或Nix env模拟器(如CygwinMSYS2等),它可能会起作用。

\n

这是[ReadTheDocs.RPy2]: Installation(其中有“在 Linux 上编译”和“在 OS X 上编译”部分,但没有关于Win 的内容,尽管它提到它应该成功编译)状态

\n
\n
    \n
  • 目前没有针对 Microsoft Windows 的二进制文件或支持(更多是因为缺乏资源)。
  • \n
\n
\n
\n\n
\n
\n
\n

更新#0

\n

添加 @pyguy 采取的步骤(来自评论),以便成功安装RPy2

\n\n