Rpy2 错误 wac-a-mole: R_USER 未定义 [英] Rpy2 error wac-a-mole: R_USER not defined

查看:67
本文介绍了Rpy2 错误 wac-a-mole: R_USER 未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows 7 32 位和 R 版本 3.1.0 上运行 Python (x,y) 2.7.我一直在尝试安装 Rpy2 并且遇到了很多错误.我终于找到了这个网站,它为 Windows http://www.lfd 预编译了 python 模块.uci.edu/~gohlke/pythonlibs/,所以我下载了 rpy2‑2.4.2.win32‑py2.7.exe.当我这样做并尝试

import rpy2.robjects 作为robjects

我有一个错误,说它找不到 R_HOME,所以我更新了我的路径变量.这是固定的,但后来我收到一个错误,说它找不到 R_USER.再一次,我根据 SO 响应更新了我的 PYTHONPATH 变量.这不起作用,所以我被卡住了.我已经在 Spyder 和系统变量中更新了我的 PYTHONPATH,但仍然没有运气.有谁知道会发生什么?这是我得到的错误:

回溯(最近一次调用最后一次):文件<stdin>",第 1 行,位于 <module>文件C:\Python27\lib\site-packages\rpy2\robjects\__init__.py",第 18 行,在 <module>从 rpy2.robjects.robject 导入 RObjectMixin, RObject文件C:\Python27\lib\site-packages\rpy2\robjects\robject.py",第 5 行,在 <module>rpy2.rinterface.initr()运行时错误:R_USER 未定义.

这是我的 PYTHONPATH 包含的内容:

C:\Python27\Lib\site-packages\rpy2;C:\Program Files\R\R-3.1.0\bin\i386;C:\Python27\Lib\site-packages\rpy2\对象

这是我的 PATH 包含的内容:

C:\Python27\Lib\site-packages\PyQt4;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files\Intel\DMIX;C:\Program Files\Intel\Services\IPT\;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages\vtk;C:\Python27\gnuplot\binary;C:\Program Files\pythonxy\SciTE-3.1.0;C:\Program Files\pythonxy\console;C:\MinGW32-xy\bin;C:\Program Files\R\R-3.1.0\bin;C:\MinGW32-xy\mingw32\bin;C:\MinGW32-xy\bin

感谢您提供的任何帮助!

解决方案

您需要设置 R_USER 环境变量,例如到您使用的 Windows 帐户的用户名.另请参阅此链接中的引用:><块引用>

1) 将 R.dll 的路径添加到我的 PATH 变量中(我去了 32 位目录) 2)添加一个环境变量 R_HOME(C:\Program Files\R\R-2.12.1 for me)3)添加环境变量R_USER(在Windows中就是我的用户名).

I'm running Python (x,y) 2.7 on windows 7 32 bit and R version 3.1.0. I've been trying to install Rpy2 and have been getting many errors. I finally found this site which has pre-compiled python modules for windows http://www.lfd.uci.edu/~gohlke/pythonlibs/, so I downloaded rpy2‑2.4.2.win32‑py2.7.exe. When I did this and tried

import rpy2.robjects as robjects

I had an error saying it could not find R_HOME, so I updated my path variables. This was fixed, but then I got an error saying it could not find R_USER. Once again, I updated my PYTHONPATH variables based on SO responses. This didn't work, and so I'm stuck. I've updated my PYTHONPATH both inside Spyder and also in my system variables, but still no luck. Does anyone know what could be going on? This is the error I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\site-packages\rpy2\robjects\__init__.py", line 18, 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()
RuntimeError: R_USER not defined.

This is what my PYTHONPATH includes:

C:\Python27\Lib\site-packages\rpy2;C:\Program Files\R\R-3.1.0\bin\i386;C:\Python27\Lib\site-packages\rpy2\robjects

This is what my PATH includes:

C:\Python27\Lib\site-packages\PyQt4;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\Program Files\Intel\DMIX;C:\Program Files\Intel\Services\IPT\;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages\vtk;C:\Python27\gnuplot\binary;C:\Program Files\pythonxy\SciTE-3.1.0;C:\Program Files\pythonxy\console;C:\MinGW32-xy\bin;C:\Program Files\R\R-3.1.0\bin;C:\MinGW32-xy\mingw32\bin;C:\MinGW32-xy\bin

Thanks for any help you can provide!

解决方案

You need to set the R_USER environment variable, e.g. to the username of the Windows account you use. See also this quote from this link:

1) Add the path to R.dll to my PATH variable (I went to the 32-bit directory) 2) Add an environment variable R_HOME (C:\Program Files\R\R-2.12.1 for me) 3) Add an environment variable R_USER (simply my username in Windows).

这篇关于Rpy2 错误 wac-a-mole: R_USER 未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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