Rpy2 problems in installation and use

Source: Internet
Author: User

Rpy2 is the R language interface module in Python, today, a afternoon, and finally put Rpy2, record the installation process need to pay attention to the problem:

1. During the R compilation process, the--enable-r-shlib option must be selected to compile R into the Lib mode, in which case the path-to-r/lib/libr.so library is generated;

At the same time, ensure that the same directory librblas.so, librlapack.so two linked libraries are also generated correctly, the two libraries are generated by default, if not, you need to add parameters:--enable-blas-shlib--with-blas-- With-lapack

Cannot compile correctly if build Libr.so,rpy2 is not compiled

2. After the installation of R is complete, if you install to a personal path, you need to add four environment variables to the configuration file:

Export R_home=path-to-r

Export r_libs= $R _home/lib64/r/library

Export ld_library_path= $R _home/lib: $LD _library_path

Export path= $R _home/bin: $PATH

It is easier to miss the PATH and Ld_library_path, if it is installed with root, there may be no problem, if installed in the personal directory, do not add these two variables, will not be able to correctly find the required dynamic link library;

The function of R_libs is to find the corresponding package according to the RPY2 when the installed R package is called.

3. Python must install Sqlite-devel before compiling the installation, otherwise it will not find the error message of the _sqlite module.

If you have already installed Python, you will need to install the Sqlite-devel library and reinstall Python;

Make sure the above three points are no problem, RPY2 installation is relatively simple, direct use

Pip Install Rpy2

Can

Check that the RPY2 is installed correctly:

>>> Import Rpy2.robjects as RB

>>> RB.R ("library (' Ade4 ')")

<StrVector-Python:0x7fccfd2a2248/R:0x2e44108>
[STR, str, str, ..., str, str, STR]

Ensure that there are no warning messages and error messages, the RPY2 is installed successfully and the installed R packages can be called correctly.

Rpy2 problems in installation and use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.