本文介绍了在Windows 7上安装rpy2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在计算机上安装rpy2,但我无法执行.

I'm trying to install rpy2 on my computer, but I wasn't able to do it.

我下载了源软件包,并尝试使用命令python setup.py install安装Rpy2(rpy2-2.3.2).结果是:

I downloaded the source package and I tryed to install Rpy2 (rpy2-2.3.2) using the command python setup.py install. This is the result:

running install
running build
running build_py
running build_ext
"C:\PROGRA~1\R\R-215~1.2\bin\R" CMD config --ldflags
"C:\PROGRA~1\R\R-215~1.2\bin\R" CMD config --cppflags
"C:\PROGRA~1\R\R-215~1.2\bin\R" CMD config LAPACK_LIBS

returned an empty string.

"C:\PROGRA~1\R\R-215~1.2\bin\R" CMD config BLAS_LIBS

returned an empty string.

Configuration for R as a library:
    include_dirs: ('C:/PROGRA~1/R/R-215~1.2/include/i386', 'C:/PROGRA~1/R/R-215~1.2/include')
    libraries: ('R',)
    library_dirs: ('C:/PROGRA~1/R/R-215~1.2/bin/i386',)
    extra_link_args: ()
   # OSX-specific (included in extra_link_args)
    framework_dirs: ()
    framework: ()
building 'rpy2.rinterface._rinterface' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
creating build\temp.win32-2.7\Release\rpy
creating build\temp.win32-2.7\Release\rpy\rinterface
C:\Rtools\gcc-4.6.3\bin\gcc.exe -mcygwin -mdll -O -Wall -DWin32=1 -I.\rpy\rinterface -IC:\Python27\include -IC:\Python27\PC -IC:/PROGRA~1/R/R-215~1.2/include/i386 -IC:/PROGRA~1/R/R-215~1.2/include -c .\rpy\rinterface\_interface.c -o build\temp.win32-2.7\Release\.\rpy\rinterface\_rinterface.o
cc1.exe: error: unrecognized command line option '-mcygwin'
error: command 'gcc' failed with exit status 1

我也尝试了build installeasy_install,但没有成功.我有R 2.15.2,Python 2.7.2和Windows 7(32位).

I also tried with build install and easy_install without success. I have R 2.15.2, Python 2.7.2 and Windows 7 (32 bit).

我在做什么错了?

PS.如果我粘贴该命令,则结果为:

PS.if I paste that command, the result is:

cygwin警告:

MS-DOS style path detected C:\PROGRA~1\R\R-215~1.2\bin\config.sh
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-215~1.2/bin/config.sh
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames

-LC:/PROGRA~1/R/R-215~1.2/bin/i386 -lR

-LC:/PROGRA~1/R/R-215~1.2/bin/i386 -lR

推荐答案

确定.根据以前的经验,我发现关于如何在Windows上安装rpy2的说明并不多.我得到它的官方支持,但实际上并不难.在几步中,我将展示我的所作所为,也许其他人可以遵循.

OK. From previous experience I've found there are not many instructions on how to install rpy2 on Windows. I get that it's not officially supported but it's really not that hard. In a few steps I'll show what I did and maybe others can follow.

这些说明很可能仅适用于Python 2.7+和R 3.2+,但可能适用于R 3.0+.我正在放置我在系统上使用过的路径. 请确保相应地修改路径:

These instructions will most likely only work for Python 2.7+ and R 3.2+ but will probably work for R 3.0+. I am putting the paths that I've used on my system. Make sure to modify the paths accordingly:

首先,在尝试执行这些步骤之前,请确保未安装任何先前的rpy2安装程序(并且在安装之前显然具有R 3.2 +).

First, make sure any previous rpy2 installations are UNINSTALLED before trying these steps (and obviously have R 3.2+ before installing).

  1. 此处
  2. 下载r2py的.whl文件.
  3. 使用pip install [put .whl filename here](在命令行中)从文件下载目录中安装.whl文件
  4. 将类似于C:\Program Files\R\R-3.2.0\bin的路径添加到PATH环境变量中
  5. 创建一个R_HOME系统变量,其值类似于:C:\Program Files\R\R-3.2.0
  6. 使用您的用户名创建R_USER系统变量
  7. 创建一个R_LIBS_USER系统变量,其路径指向将要安装/将要安装外部R软件包的文件夹.
  1. Download the .whl file for r2py from here
  2. Install the .whl file using pip install [put .whl filename here] (in the command line) from the directory where the file was downloaded
  3. Append a path similar to C:\Program Files\R\R-3.2.0\bin to your PATH environment variable
  4. Create a R_HOME system variable with a value similar to: C:\Program Files\R\R-3.2.0
  5. Create a R_USER system variable with your user name
  6. Create a R_LIBS_USER system variable with a path to the folder where external R packages are/will be installed.

就是这样.打开命令提示符,然后输入命令R.这将启动R会话并显示版本信息.

That's it. Open up a command prompt and enter the command R. This should start an R session and display version information.

现在打开python并运行以下行以查看是否可行:

Now open up python and run this line to see if things worked out or not:

import rpy2.robjects as robjects

希望这会有所帮助.

这篇关于在Windows 7上安装rpy2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:53