简体   繁体   中英

rpy2 error symbol 'R_tryCatchError' not found in library '/usr/lib/R/lib/libR.so'

Python: 3.7.6

rpy2: 3.2.7

R: 3.3.3

I'm using GCE at AI Platform to perform some clustering. I've installed the r-base, updated properly, installed the python-rpy2 and I'm getting this error.

import rpy2.robjects as robjects

error: symbol 'R_tryCatchError' not found in library '/usr/lib/R/lib/libR.so': /usr/lib/R/lib/libR.so: undefined symbol: R_tryCatchError

Someone could help me?

R is too old for the rpy2 version you are trying to use.

I'd recommend to update R (the latest R release is 3.6.x), as well as rpy2 (the latest release is 3.3.1).

To provide an actionable code snippet, this worked for me

R --version  # older, < 3.6 version
sudo apt-get remove r-base r-base-core r-base-dev r-recommended
sudo vim /etc/apt/sources.list # for Ubuntu, from https://cran.r-project.org/bin/linux/ubuntu/README.html, remove old cran links and insert the one matching your Ubuntu LTS distro
apt-cache showpkg r-base # should show R version you want e.g. 3.6 or 4.0
sudo apt-get install r-base r-base-core r-base-dev r-recommended
R --version # should be newer
sudo apt-get install python-rpy2 # real data scientists play no favorites
#pip install rpy2; echo "import rpy2.robjects as robjects | python # should work

As @igautier mentioned, the cause was a very old version of R but a fix is above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM