使用rpy2时出现错误。我认为主要问题是rpy2链接到我的系统上可能不再存在的旧R版本。
我前一段时间安装了rpy2,当时可能有一个较旧的R版本。我试图通过重新安装rpy2来解决此问题,但没有成功。
python3 -m rpy2.tests
导致
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: Warnmeldung:
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: In local({ :
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: nicht passende Bytecode Versionen; nutze eval
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: Fehler in !value : ungültiger Argumenttyp
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: Zusätzlich:
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: Paket ‘methods’ wurde unter R Version 3.4.4 erstellt
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: Warnmeldungen:
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: 1: Paket ‘datasets’ wurde unter R Version 3.4.4 erstellt
warnings.warn(x, RRuntimeWarning)
/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/rinterface/__init__.py:146: RRuntimeWarning: 2: Paket ‘utils’ wurde unter R Version 3.4.4 erstellt
warnings.warn(x, RRuntimeWarning)
rpy2 version: 2.9.5
- built against R version: 3-4.4--74408
- running linked to R version: R version 3.3.1 (2016-06-21)
E
======================================================================
ERROR: __main__ (unittest.loader._FailedTest)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/tests.py", line 43, in load_tests
suite_robjects = loader.discover('robjects', pattern, rpy_root)
File "/usr/lib/python3.5/unittest/loader.py", line 290, in discover
__import__(start_dir)
File "/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/robjects/__init__.py", line 19, in <module>
from rpy2.robjects.robject import RObjectMixin, RObject
File "/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/robjects/__init__.py", line 19, in <module>
from rpy2.robjects.robject import RObjectMixin, RObject
File "/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/robjects/robject.py", line 52, in <module>
class RObjectMixin(object):
File "/usr/local/lib/python3.5/dist-packages/rpy2-2.9.5-py3.5-linux-x86_64.egg/rpy2/robjects/robject.py", line 66, in RObjectMixin
__show = rpy2.rinterface.baseenv.get("show")
LookupError: 'show' not found
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
我想主要问题如下:
针对R版本构建的:3-4.4--74408与我当前的R版本一样。这应该是正确的。 但是运行链接到R版本:R版本3.3.1(2016-06-21)似乎是错误的。我非常确定我的系统上不再存在这样的版本。但这可能是我第一次安装rpy2时使用的版本。
我的系统是Ubuntu 16.04,我正在使用Python 3.5.2(默认值,2018年11月12日,13:43:14),R版本3.4.4(2018-03-15)和rpy2-2.9.5-py3 .5-linux-x86_64。
非常感谢您。
编辑: 我现在更加困惑了。
python3 -m rpy2.situation
给予
Python version:
3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609]
Looking for R's HOME:
Environment variable R_HOME: None
Calling `R RHOME`: /usr/lib/R
InstallPath in the registry: *** Only available on Windows ***
R version:
In the PATH: R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Used to build rpy2: 3-4.4--74408
Additional directories to load R packages from:
None
这看起来完全正常。我仍然不知道为什么rpy2链接到R版本3.3.1。
答案 0 :(得分:0)
您可以尝试以下方法以获得有关rpy2的构建方式以及在运行时找到的R版本的信息:
python -m rpy2.situation
除此之外,您可能还要检查是否设置了环境变量LD_LIBRARY_PATH
或LD_PRELOAD
,因为它可能会影响加载哪个R共享库。