rpy2 install on windows 7

前端 未结 9 850
轮回少年
轮回少年 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:09

    On Anaconda, you can install using:

    conda install --channel https://conda.anaconda.org/Richarizardd rpy2
    

    Alternativey, can be tried:

    conda install -c r rpy2 
    

    One can also refer:

    https://github.com/conda-forge/rpy2-feedstock
    
    0 讨论(0)
  • 2020-11-27 03:10

    I just successfully installed rpy2 on Windows 8.1 64bit with the binary installer from http://www.lfd.uci.edu/~gohlke/pythonlibs/#rpy2. It is usually much easier to just download a binary instead of trying to compile a package in Windows.

    Also, you should set R_HOME environmental variable (in my case, to C:\Program Files\R\R-3.1.1) before you install the rpy2 binary. Otherwise you get RuntimeError: R_HOME not defined. error when you try to import rpy2. (thanks to R_HOME Error with rpy2)

    Lastly, make sure to use %load_ext rpy2.ipython instead of %load_ext rmagic if you want to use it in IPython. It is one of the new features in rpy2 version 2.4.0.

    (thanks to IPython notebook and rmagic/rpy2: cannot find module ri2py (OSX 10.8.5, python 2.7, R 3.1))

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

    EDIT Finally I managed to get it to work!!! See below:

    I have been banging my head to get this to work and still haven't figured it out completely. What I have found out is that the error

    'sh' is not recognized as an internal or external command, operable program or batch file

    is caused by the absence of mingw and Rtools (and other unix like helper programs). (http://sourceforge.net/p/rpy/mailman/message/26549197/)

    I went passed this stage by installing Rtools (http://cran.r-project.org/bin/windows/Rtools/) and mingw (http://sourceforge.net/projects/mingw-w64/) (But since the mingw-w64 project on sourceforge.net is moving to mingw-w64.org i suggest to use mingw-w64.org)

    I went passed the R.exe CMD config --ldflags error but got stuck with

    TypeError: object of type 'NoneType' has no len()

    error. I am still searching for a solution!!

    Hope this helps someone at some point.

    UPDATE : So it seems that there are couple of problems associated with the installation. The setup.py is not able to find the correct version of R and the compilers have issues.

    So, the way to proceed :

    1. Download the source code from https://pypi.python.org/pypi/rpy2.
    2. Update your environment variables - In the user variables
      • PATH : append the path to ur R installation eg ;C:\Program Files\R\R-3.0.2\bin\x64
      • R_HOME : a new variable with path to R: C:\Program Files\R\R-3.0.2
      • R_USER : user user name eg john
    3. Install Rtools (http://cran.r-project.org/bin/windows/Rtools/) and mingw (http://mingw-w64.org)
    4. around line 123 before

      return self._version I added self._version = [3, 0] to force the version to be 3.0 (may be someone can solve this better)

    5. In the file unixccompiler.py either in python27/lib/distutils or in my case C:\Users(user_name)\AppData\Local\Continuum\Anaconda\Lib\distutils comment line 227

    compiler = os.path.basename(sysconfig.get_config_var("CC")) with # (#compiler = os.path.basename(sysconfig.get_config_var("CC")))

    and add line

    compiler = 'gcc'

    Some other things - use the command prompt cmd for installing. Use

    python setup.py build install

    Install the Rtools and mingw accepting all defaults. In Rtools select the

    extra to build 64 bit R

    and

    edit the system PATH

    Thats it!! Got it to work..

    Hope this helps!!

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

    Check out this install doc I made about this issue. https://www.academia.edu/12178754/rpy2Install

    It's directory specific to an ArcGIS setup, but quick to port

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

    I am not sure if anyone is still following the discussion but in any case, My aim in trying to get rpy2 to work was so to be able to get it working in my Ipython notebooks. If anyone else is trying to do the same, I would suggest using IRkernel which installs smoothly as a cake (well made cake). Here are the resources to get it done. I have used it and it works like a charm.

    basically what you need to run is this:

    install.packages(c('rzmq','repr','IRkernel','IRdisplay'),repos = c('http://irkernel.github.io/', getOption('repos')))
    
    IRkernel::installspec()
    

    Here are the resources if you find any troubles:

    https://github.com/IRkernel/IRkernel

    http://blog.revolutionanalytics.com/2015/09/using-r-with-jupyter-notebooks.html

    http://www.michaelpacer.com/maths/r-kernel-for-ipython-notebook

    HTH

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

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

    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.

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