在 Windows 上安装 rpy2

问题描述 投票:0回答:1

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

pip install rpy2

我得到一个不同的错误:

Command '('c:\PROGRA~1\R\R-34~1.4 in\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\
python rpy2
1个回答
6
投票

输出包含错误:

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

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

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

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


更新#0

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

© www.soinside.com 2019 - 2024. All rights reserved.