我想在我的Labtop上使用rpy2库。但是我整个上午都没有安装。
这里有几个问题。任何建议,将不胜感激!
使用pip install rpy2
。结果显示如下:
Complete output from command python setup.py egg_info:
Error: Tried to guess R's HOME but no command (R) in the PATH.
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\hyf\appdata\local\temp\pip-build-gkdpb0\rpy2\
然后,我读了一些帖子。有人告诉您使用.whl格式的软件包可以解决此问题。SO:pip install rpy2-2.7.8-cp27-none-win_amd64.whl
用于安装我下载的软件包。失败:
IOError: [Errno 13] Permission denied: 'D:\\Program\\Anaconda\\Lib\\site-packages\\rpy2\\rinterface\\_rinterface.pyd'
使用conda install --channel https://conda.binstar.org/joshadel rpy2
,可以安装rpy2软件包。
但是当我在ipython笔记本中这样称呼它时:
import rpy2
from rpy2.robjects import r
结果显示错误:
RuntimeError: R_HOME not defined.
但是我已经将环境变量添加到系统变量中,如下所示:
R_HOME:D:\Program\R\bin\x64
R_User:D:\Program\Anaconda\Lib\site-packages\rpy2
我正在使用带有Python2.7内核和R 3.2.2的Anaconda。
显然,R_HOME
应该从__init__
文件中引用根R目录,出现以下几行
# Load the R dll using the explicit path
R_DLL_DIRS = ('bin', 'lib')
# Try dirs from R_DLL_DIRS
for r_dir in R_DLL_DIRS:
Rlib = os.path.join(R_HOME, r_dir, _win_bindir, 'R.dll')
此处_win_bindir
将指代x64或32位版本。因此,可以从外壳程序(或更永久地更改系统设置)中,将环境变量设置为
set R_HOME=D:\Program\R
并尝试使用python(从该shell!)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句