我是Python的新手(以及一般的编程)我来自金融背景,所以请耐心等待.我刚开始使用Python(Enthought的Pylab/Scipy/Numpy)和R进行统计分析.我正在尝试将rpy2安装到Python中以集成R,但我得到错误:
试图猜测R的HOME但在PATH中没有R命令.
我不确定这意味着什么.我的R.exe的路径是"C:\ Program Files\R\R-2.12.1\bin",如果它有用的话.任何帮助将非常感激!
这是setup.py的代码
import os, os.path, sys, shutil, re, itertools
from distutils.command.build_ext import build_ext as _build_ext
from distutils.command.build import build as _build
from distutils.core import setup
from distutils.core import Extension
pack_name = 'rpy2'
pack_version = __import__('rpy').__version__
class build(_build):
user_options = _build.user_options + \
[
#('r-autoconfig', None,
# "guess all configuration paths from " +\
# "the R executable found in the PATH " +\
# "(this overrides r-home)"),
('r-home=', None,
"full path for the R home to …Run Code Online (Sandbox Code Playgroud) 我正在尝试安装rpy2包并获得以下错误
C:\python27>easy_install rpy2
Searching for rpy2
Reading http://pypi.python.org/simple/rpy2/
Reading http://rpy.sourceforge.net
Best match: rpy2 2.3.3
Downloading http://pypi.python.org/packages/source/r/rpy2/rpy2-2.3.3.tar.gz#md5=6cd95eb70645577cb53198ef0a32395e
Processing rpy2-2.3.3.tar.gz
Running rpy2-2.3.3\setup.py -q bdist_egg --dist-dir c:\users\chetan~1\appdata\local\temp\easy_install-wfxip9\rpy2-2.3.3\egg-di
st-tmp-rrezfb
"C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags
Invalid substring
in string
C:\Python27\lib\site-packages\setuptools\command\easy_install.py:921: RuntimeWarning: tp_compare didn't return -1 or -2 for ex
ception
raise DistutilsError("Setup script exited with %s" % (v.args[0],))
error: Setup script exited with Problem while running `"C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags`
Run Code Online (Sandbox Code Playgroud)
当我尝试pip时,这就是我得到的
c:\Python27\Lib\site-packages\django\bin>pip install rpy2
Run Code Online (Sandbox Code Playgroud)
下载/解压缩rpy2运行setup.py egg_info包rpy2
"C:\PROGRA~2\R\R-28~1.0\bin\R" CMD config --ldflags
Invalid substring
in string
Problem while …Run Code Online (Sandbox Code Playgroud) 我知道有很多关于在Windows 7 32位上启动和运行rpy2的帖子.我已经引用了很多这些并尝试了他们的解决方案,包括使用PypeR.
我没有在我的路径中明确设置R_HOME变量,但根据这个问题,我确认R在我的PATH中(我可以R在命令行输入并让R运行)甚至复制了i386文件夹中的所有文件到父bin文件夹.
我的问题粘贴在下面.有什么想法吗?
In [5]: from rpy2 import robjects
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-1f019d00d232> in <module>()
----> 1 from rpy2 import robjects
C:\Anaconda\lib\site-packages\rpy2\robjects\__init__.py in <module>()
16 import rpy2.rlike.container as rlc
17
---> 18 from rpy2.robjects.robject import RObjectMixin, RObject
19 from rpy2.robjects.vectors import *
20 from rpy2.robjects.functions import Function, SignatureTranslatedFunction
C:\Anaconda\lib\site-packages\rpy2\robjects\robject.py in <module>()
3 import rpy2.rinterface
4
----> 5 rpy2.rinterface.initr()
6
7 import conversion
RuntimeError: R_HOME not defined.
Run Code Online (Sandbox Code Playgroud) 我正试图通过Enthought Canopy使用Python 2.7.6来使用IPython笔记本的rmagic扩展.
当我尝试以下示例时:
import numpy as np
import pylab
X = np.array([0,1,2,3,4])
Y = np.array([3,5,4,6,7])
pylab.scatter(X, Y)
%Rpush X Y
%R lm(Y~X)$coef
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
AttributeError Traceback (most recent call last)
<ipython-input-7-96dff2c70ba0> in <module>()
1 get_ipython().magic(u'Rpush X Y')
----> 2 get_ipython().magic(u'R lm(Y~X)$coef')
…
/Users/hrob/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/extensions/rmagic.pyc in eval(self, line)
212 res = ro.r("withVisible({%s})" % line)
213 value = res[0] #value (R object)
--> 214 visible = ro.conversion.ri2py(res[1])[0] #visible (boolean)
215 except (ri.RRuntimeError, ValueError) as exception:
216 warning_or_other_msg = self.flush() # otherwise next return …Run Code Online (Sandbox Code Playgroud) 我试图为我的问题找到解决方案,到目前为止还没有成功.
我正在尝试在我的计算机上安装最新的Rpy2版本.我已经安装了所有必需的程序(R 2.15.1和2.7 Python).我正在使用命令安装Rpp2(rpy2-2.3.0)
python setup.py build install
我得到这个追溯:
Traceback(最近一次调用最后一次):
文件"setup.py",第441行,in
[os.path.join('doc','source','rpy2_logo.png')])],
在设置中文件"c:\ Python27\lib\distutils\core.py",第152行
dist.run_commands()
在run_commands中的文件"c:\ Python27\lib\distutils\dist.py",第953行
self.run_command(CMD)
在run_command中输入文件"c:\ Python27\lib\distutils\dist.py",第972行
cmd_obj> run()的
运行中的文件"c:\ Python27\lib\distutils\command\install.py",第563行
self.run_command( '建立')
在run_command中的文件"c:\ Python27\lib\distutils\cmd.py",第326行
self.distribution.run_command(命令)
在run_command中输入文件"c:\ Python27\lib\distutils\dist.py",第972行
cmd_obj.run()
在运行中文件"c:\ Python27\lib\distutils\command\build.py",第127行
self.run_command(cmd_name)
在run_command中的文件"c:\ Python27\lib\distutils\cmd.py",第326行
self.distribution.run_command(命令)
在run_command中的文件"c:\ Python27\lib\distutils\dist.py",第971行
cmd_obj.ensure_finalized()
文件"c:\ Python27\lib\distutils\cmd.py",第109行,在ensure_finalized中
self.finalize_options()
在finalize_options中的文件"setup.py",第152行
config + = get_rconfig(r_home,about)
在get_rconfig中的文件"setup.py",第312行
rc = RConfig.from_string(rconfig,allow_empty = allow_empty)
在from_string中的文件"setup.py",第272行
- '\nin string \n'+ string)
ValueError:无效的子字符串
在字符串中
我尝试安装时遇到的错误相同
easy_install rpy2
更新:现在相同的错误显示在另一台PC(64位)
感谢帮助!:d
我在 Windows 10 上运行 miniconda。我已经安装了 rpy2 并且过去使用它没有任何问题。最近我从 pandas 版本 0.24.0 升级到 0.25.1。在发现这破坏了我一直在开发的自定义包后,我决定降级回 pandas 版本 0.24.0。完成所有这些后,当我尝试使用以下命令导入对象时:
import rpy2.robjects as ro
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-5-d790458a85bf> in <module>
----> 1 import rpy2.robjects as ro
C:\ProgramData\Miniconda3\lib\site-packages\rpy2\robjects\__init__.py in <module>
12 import types
13 import array
---> 14 import rpy2.rinterface as rinterface
15 import rpy2.rlike.container as rlc
16
C:\ProgramData\Miniconda3\lib\site-packages\rpy2\rinterface.py in <module>
4 import math
5 import typing
----> 6 from rpy2.rinterface_lib import openrlib
7 import rpy2.rinterface_lib._rinterface_capi as _rinterface
8 import rpy2.rinterface_lib.embedded …Run Code Online (Sandbox Code Playgroud) 我尝试安装rpy2但我在下面有这个错误.
我在网上看到问题是环境变量,但我在系统变量路径中有 C:\ Rtools\bin和C:\ Program Files\R\R-3.2.2\bin.
我究竟做错了什么?
错误:
C:\Users\rmalveslocal>pip install rpy2
Collecting rpy2
Downloading rpy2-2.7.6.tar.gz (177kB)
100% |################################| 180kB 1.3MB/s
Complete output from command python setup.py egg_info:
R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3. …Run Code Online (Sandbox Code Playgroud)