I am receiving errors when using rpy2. I think the main issue is that rpy2 links to an old R version which is probably not existing on my system anymore.
I installed rpy2 a while ago and probably had an older R version at that time. I tried to solve the problem by reinstalling rpy2 but without success.
python3 -m rpy2.tests
leads to
/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)
I guess the main issue is the following:
built against R version: 3-4.4--74408 is as expected my current R version. This should be correct. But running linked to R version: R version 3.3.1 (2016-06-21) seems wrong. I am pretty sure such a version is not existing on my system anymore. But it might be the version that I had when installing rpy2 for the first time.
My system is Ubuntu 16.04 and I am using Python 3.5.2 (default, Nov 12 2018, 13:43:14) , R version 3.4.4 (2018-03-15) and rpy2-2.9.5-py3.5-linux-x86_64.
Thank you very much in advance.
Edit: I am even more puzzeled now.
python3 -m rpy2.situation
gives
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
This looks completely fine. I have still no idea why rpy2 links to R version 3.3.1.
You could try the following to obtain information about how rpy2 was built and where is the R version it finds at runtime:
python -m rpy2.situation
In addition to this, you may want to check whether you have set the environment variables LD_LIBRARY_PATH
or LD_PRELOAD
as it might influence which R shared library is loaded.