python - error install rpy2 : 'sh' is not recognized as an internal or external command, 可运行程序或批处理文件

标签 python r system rpy2

我尝试安装 rpy2 但出现以下错误。

我在网上看到问题出在环境变量上,但我有 C:\Rtools\binC:\Program Files\R\R-3.2.2\bin 在系统变量路径中。

我做错了什么?

错误:

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

最佳答案

  1. 在这里下载你需要的版本http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2
  2. 打开 Anaconda Prompt 并导航到您下载文件的文件夹
  3. 运行 pip install file_name.whl

关于python - error install rpy2 : 'sh' is not recognized as an internal or external command, 可运行程序或批处理文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34512910/

相关文章:

linux - 使用 bash exec 命令调用 R

r - 如何在R中导入编号文件

c - 关于c中struct深拷贝和浅拷贝的问题

variables - 如何在 NAnt 脚本中使用系统变量?

python - 为什么 str(float) 在 Python 3 中返回的位数比 Python 2 多?

python - 在 Python 中使用 Dateutil 时提取某些日期格式失败

python - 使用 Selenium (Python3) 抓取网站的多个页面

r - 如何在 R 中的 read_html 之后关闭未使用的连接

python - Django 中所有模型的通用 app_label

java - 如何让 Java 程序在几秒钟后退出