如何设置环境变量R_user在python中使用rpy2 [英] How to setup environment variable R_user to use rpy2 in python

查看:2065
本文介绍了如何设置环境变量R_user在python中使用rpy2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在python中运行rpy2。



与此代码

  import rpy2.robjects as robjects 

以下是完整的例外:






RuntimeError:R_USER未定义。



文件d:\py\r\r.python.py,第1行,在

 将rpy2.robjects导入为robjects 

文件c:\Python27\Lib \site-packages\rpy2\robjects\__init __。py,第17行,< module>
from rpy2.robjects.robject import RObjectMixin,RObject

文件c:\Python27\Lib\site-packages\rpy2\robjects\robject.py,第5行,< module>
rpy2.rinterface.initr()






我正在使用窗口xp win32这里是我的位置:

  C:\Python27\Lib\site- package\rpy2\robjects\robject.py 

C:\Program Files\R\R-2.15.0\bin\i386\R.exe

C:\Python27\python.exe


解决方案

这是我修复我的 R 包版本 3.0.2 python版本 2.7 平台ipython笔记本的方式。



更改R计算机的路径 - >属性 - >高级和系统设置 - >环境变量



在用户变量字段中添加 C:\Program Files\R\R-3.0.2\bin\x64 (我的系统是Windows 64位)到路径



在系统变量字段中添加两个新变量



R_HOME c:\program files\r\ R- 3.0.2



R_USER C:\Users\您的用户名\Anaconda\Lib \site-packages\rpy2


I 'm unable to run rpy2 in python.

with this code

 import rpy2.robjects as robjects

Here's the full exceptions:


RuntimeError: R_USER not defined.

File "d:\py\r\r.python.py", line 1, in

  import rpy2.robjects as robjects

File "c:\Python27\Lib\site-packages\rpy2\robjects\__init__.py", line 17, in <module>
  from rpy2.robjects.robject import RObjectMixin, RObject

File "c:\Python27\Lib\site-packages\rpy2\robjects\robject.py", line 5, in <module>
  rpy2.rinterface.initr()


I'm using window xp win32 Here're my locations:

C:\Python27\Lib\site-packages\rpy2\robjects\robject.py

C:\Program Files\R\R-2.15.0\bin\i386\R.exe

C:\Python27\python.exe

解决方案

Here is the way I fixed my R package version 3.0.2 python version 2.7 platform ipython notebook.

Change Path for R computer-> property -> advanced and system setting -> environment variables

in the user variable field add C:\Program Files\R\R-3.0.2\bin\x64 (my system is windows 64bit) to path

In the system variable field add two new variables

R_HOME c:\program files\r\r-3.0.2

R_USER C:\Users\"your user name"\Anaconda\Lib\site-packages\rpy2

这篇关于如何设置环境变量R_user在python中使用rpy2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆