在Jupyter Notebook或控制台中加载rpy2会给我带来以下错误:
Traceback (most recent call last):
File "/home/louis/anaconda3/lib/python3.5/runpy.py", line 184, in _run_module_as_main
"__main__", mod_spec)
File "/home/louis/anaconda3/lib/python3.5/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/tests.py", line 23, in <module>
import rpy2.tests_rpy_classic
File "/home/louis/anaconda3/lib/python3.5/site- packages/rpy2/tests_rpy_classic.py", line 3, in <module>
import rpy2.rpy_classic as rpy
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/rpy_classic.py", line 5, in <module>
import rpy2.rinterface as ri
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /home/louis/anaconda3/lib/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/lib/R/lib/libR.so)
我不知道它有多相关,但是我安装了gcc,我可以在python中导入rpy2。
非常感谢任何帮助或提示。
按照omri_saadon的评论,我将LD_LIBRARY_PATH
设置为导致libgomp目录的所有路径,它们是:
但每次都有同样的错误:
ImportError: path_to_libgomp/libgomp.so.1: version `GOMP_4.0' not found (required by /usr/lib/R/lib/libR.so)
所以我的任务继续^^(我必须承认我并不知道我在做什么的来龙去脉。)
当我成功设置export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu
(在root模式下找到)时,我有另一种错误:
import rpy2.rinterface as ri
File "/home/louis/anaconda3/lib/python3.5/site- packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /home/louis/anaconda3/bin/../lib/libreadline.so.6: undefined symbol: PC
然后当我尝试首先导入readline
包(因为它似乎与某些包合作)时,我得到:
import rpy2.rinterface as rinterface
File "/home/louis/anaconda3/lib/python3.5/site-packages/rpy2/rinterface/__init__.py", line 92, in <module>
from rpy2.rinterface._rinterface import (baseenv,
ImportError: /usr/lib/libblas.so.3: undefined symbol: gotoblas
答案 0 :(得分:1)
看来我终于成功安装并使用了rpy2。
我做了什么?
我用conda包管理器安装它,而不是pip。只有conda install rpy2
,我就完成了。
答案 1 :(得分:0)
你试过吗
RUN conda install -y gcc
这似乎适用于有类似问题的人 - Missing GOMP_parallel or GOMP_4.0 in (Docker) jupyter/all-spark-notebook: both R and Python