RPY2 Environment Configuration
Recently, I want to integrate R into a web system with flask as a back-end framework, and perform data statistics analysis on the server side. The R language needs to be integrated into Python, and it is found that Rpy2 in Python can invoke the R language, so it took some time to configure the Rpy2. Do a summary.
-
install R and configure the system environment
① Note: The version of R is compatible with the Python version. ② System Environment configuration (in my case): Add or modify in system variables and User variables: path: Add R.dll path such as: C:\program files\r\r-3.1.2\bin\x64 R_HOME: R installation path such as: C:\program files\r \r-3.1.2 R_user:r installation path such as: C: \program files\r\R-3.1.2
Installing the RPY2 Package
①在第三方库下载非官方Rpy2安装文件"XXX.whl",[网址][1]http://www.lfd.uci.edu/~gohlke/pythonlibs。注意: !Rpy2包与R、python的版本要一致 !Rpy2与R必须都是32位或者都是64位②使用pip安装 打开CMD,转到python的安装目录,我的目录是c:\python27\scripts 输入代码:Pip install ‘XXX.whl’
Test is configured successfully
打开cmd,转到python的安装目录,输入测试代码: Import rpy2.robjects as rb
Data Analysis R&PYTHON-RPY2 Package environment configuration