问题描述
我正在尝试在运行 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
我收到一个不同的错误:
Command '('c:\PROGRA~1\R\R-34~1.4\bin\x64\R', 'CMD', 'config', '--ldflags')' 返回非零退出状态1
完整的输出如下.知道我做错了什么吗?
pip install rpy2收集 rpy2下载 https://files.pythonhosted.org/packages/88/f7/788e5e1587bc1ab48b5b0467f9c3a08ef5aadbd993ed835559a10e452121/rpy2-2.9.3.tar.gz (193k)命令 python setup.py egg_info 的完整输出:R 版本 3.4.4 (2018-03-15) -- 有人可以依靠"版权所有 (C) 2018 R 统计计算基金会平台:x86_64-w64-mingw32/x64(64位)R 是免费软件,绝对没有任何保证.欢迎您根据条款重新分发它GNU 通用公共许可证版本 2 或 3.有关这些问题的更多信息,请参阅http://www.gnu.org/licenses/.'sh' 不被识别为内部或外部命令,可运行的程序或批处理文件.R 版本 3.4.4 (2018-03-15) -- 有人可以依靠"c:\PROGRA~1\R\R-34~1.4\bin\x64\R CMD 配置 --ldflags回溯(最近一次调用最后一次):文件<string>",第 1 行,在 <module>文件C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\setup.py",第 374 行,在 <module> 中.ri_ext = getRinterface_ext()文件C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\setup.py",第 269 行,在 getRinterface_extldf = shlex.split(' '.join(rexec.cmd_config('--ldflags')))文件C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\setup.py",第 222 行,在 cmd_configUniversal_newlines = True)文件c:\users\py\miniconda3\lib\subprocess.py",第 626 行,在 check_output 中**kwargs).stdout文件c:\users\py\miniconda3\lib\subprocess.py",第 708 行,运行中输出=标准输出,标准错误=标准错误)subprocess.CalledProcessError: Command '('c:\\PROGRA~1\\R\\R-34~1.4\\bin\\x64\\R', 'CMD', 'config', '--ldflags')' 返回非零退出状态 1---------------------------命令python setup.py egg_info"在 C:\Users\py\AppData\Local\Temp\pip-build-qz4rb_4o\rpy2\ 中失败,错误代码为 1
输出包含错误:
'sh' 不被识别为内部或外部命令
但我认为这只是一个警告(因为后面有输出).sh (shell) 是 Nix 特定的,并且(自然地)在 Win 上不存在.但是,如果您为 Win 安装了端口,或者 Lnx env 模拟器(例如 Cygwin),它可能会工作.
以下是[ReadTheDocs.rpy2]:安装(其中包含在 Linux 上编译"和在 OS X 上编译"部分,但没有关于 Win,尽管它提到它应该编译成功)状态:
目前没有对 Microsoft Windows 的二进制文件或支持(更多是因为缺乏资源而不是其他任何东西).
Microsoft 的 Windows - 非官方和不受支持的二进制文件由 Christoph Gohlke 提供 (http://www.lfd.uci.edu/~gohlke/pythonlibs);否则目前几乎不支持此平台
更新#0
添加@pyguy 采取的步骤(来自评论),以便成功安装 rpy2:
- 从 (32 位,下载*win32.whl)
- 在.whl的下载目录 cmd窗口(作为管理员)>
- 将 R_USER env var 设置为当前用户名:
set R_USER=%USERNAME%
python -m pip install rpy2‑2.9.3‑cp35‑cp35m‑win_amd64.whl
(Python 的(二进制)dir必须在%PATH%中,或者指定完整路径)
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 Files\R\R-3.4.4\bin\ to my path environment variable. Now when I do
pip install rpy2
I get a different error:
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~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\
The output contains the error:
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:
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)
这篇关于在 Windows 上安装 rpy2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!