rpy2 install on windows 7

前端 未结 9 851
轮回少年
轮回少年 2020-11-27 02:50

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 <

相关标签:
9条回答
  • 2020-11-27 03:27

    The install script setup.py is telling that a problem was met when running

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

    Open a terminal, paste that command, check what the error is.

    As you edited the question with the output the problem seems to be that while running that command as a subprocess from python setup.py install an empty string is returned while when running the command from a terminal there is an output. I am also reading from the output from the terminal that cygwin is involved. May be this is the problem ?

    0 讨论(0)
  • 2020-11-27 03:30

    Following the answers above, this is what works for me

    System: Win 7-64, Python 3.6,

    1. Install R and packages you need

    2. Set R_HOME and R_USER, as environment variable

    R_HOME = D:\Program Files\R\R-3.4.1
    R_USER = Administrator 
    

    The user name can be obtained by echo %username% in cmd

    3. Download rpy2 and install it

    Download rpy2 from http://www.lfd.uci.edu/~gohlke/pythonlibs/

    Check to its path, and install it in cmd like pip install rpy2-2.8.6-cp36-cp36m-win_amd64.whl

    4. Create a notebook and see if it works

    import rpy2.robjects as robjects
    
    # test : evaluating R code
    robjects.r('''
            # create a function `f`
            f <- function(r, verbose=FALSE) {
                if (verbose) {
                    cat("I am calling f().\n")
                }
                2 * pi * r
            }
            # call the function `f` with argument value 3
            f(3)
            ''')
    
    0 讨论(0)
  • 2020-11-27 03:31

    I also generally had no success getting Rpy2 to work on Windows. After a few hours hacking around with R2.15 and Rpy2 from the pre-compiled binary 2.3.4.win-amd64-py2.7, I followed this question, and installed pyper instead. Maybe this will work for you until the support is there. I for one would love to see Rpy2 on Windows and IPython notebook (%load_ext rmagic), but I just couldn't spend any more time with it.

    0 讨论(0)
提交回复
热议问题