希望有人可以帮助解决这个问题。
R版本:2.14.1
rpy2版本:2.2.5
python版本:2.7.3
一直在尝试在 python 脚本中使用 rpy2 加载具有 rJava 作为依赖项的 R venneuler 包。venneuler 和 rJava 都成功地从 R 环境中加载。其他 R 库,例如“stats”、“car”等,可以使用 rpy2 中的 importr 在 python 中加载。
Python代码:
>from rpy2 import robjects
>from rpy2.robjects.packages import importr
>venn=importr('venneuler')
这给出了以下错误:
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘venneuler’
Error in .Primitive("as.environment")("package:venneuler") :
no item called "package:venneuler" on the search list
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/rpy2/robjects/packages.py", line 117, in importr
env = _as_env(rinterface.StrSexpVector(['package:'+name, ]))
rpy2.rinterface.RRuntimeError: Error in .Primitive("as.environment")("package:venneuler") :
no item called "package:venneuler" on the search list
在排查过程中,我尝试使用importr直接加载rJava:
>java=importr('rJava')
得到以下错误,
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/home/adam/R/x86_64-pc-linux-gnu-library/2.14/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error in .Primitive("as.environment")("package:rJava") :
no item called "package:rJava" on the search list
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/rpy2/robjects/packages.py", line 117, in importr
env = _as_env(rinterface.StrSexpVector(['package:'+name, ]))
rpy2.rinterface.RRuntimeError: Error in .Primitive("as.environment")("package:rJava") :
no item called "package:rJava" on the search list
当我检查'/home/adam/R/x86_64-pc-linux-gnu-library/2.14/rJava/libs/rJava.so'时,它存在并且似乎正确链接到java动态库(例如ldd rJava.so) .
关于如何解决这个问题的任何想法?