Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
157 views
in Technique[技术] by (71.8m points)

python - rpy2 install on windows 7

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

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~1RR-215~1.2inR" CMD config --ldflags
"C:PROGRA~1RR-215~1.2inR" CMD config --cppflags
"C:PROGRA~1RR-215~1.2inR" CMD config LAPACK_LIBS

returned an empty string.

"C:PROGRA~1RR-215~1.2inR" 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 buildemp.win32-2.7
creating buildemp.win32-2.7Release
creating buildemp.win32-2.7Release
py
creating buildemp.win32-2.7Release
py
interface
C:Rtoolsgcc-4.6.3ingcc.exe -mcygwin -mdll -O -Wall -DWin32=1 -I.
py
interface -IC:Python27include -IC:Python27PC -IC:/PROGRA~1/R/R-215~1.2/include/i386 -IC:/PROGRA~1/R/R-215~1.2/include -c .
py
interface\_interface.c -o buildemp.win32-2.7Release.
py
interface\_rinterface.o
cc1.exe: error: unrecognized command line option '-mcygwin'
error: command 'gcc' failed with exit status 1

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).

What am I doing wrong?

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

cygwin warning:

MS-DOS style path detected C:PROGRA~1RR-215~1.2inconfig.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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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:

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

  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 FilesRR-3.2.0in to your PATH environment variable
  4. Create a R_HOME system variable with a value similar to: C:Program FilesRR-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.

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

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

import rpy2.robjects as robjects 

Hopefully this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...