简体   繁体   English

无法使用Rpy2

[英]Unable to use Rpy2

Why I try to load Rpy2 in Python, the interpreter finds the module but as soon as I try to import anything from it, it returns an error: 为什么我尝试加载Rpy2在Python,解释发现的模块,但只要我尝试从它导入任何东西,它会返回一个错误:

eg 例如

import rpy2 # No errors, although it does not print anything

But

import rpy2.robjects 

returns the following error: 返回以下错误:

/home/jimmy/.python_easy_install/rpy2-2.3.0beta1-py2.7-linux-x86_64.egg/rpy2/rinterface/_rinterface.so: undefined symbol: Rf_translateCha rUTF8 /home/jimmy/.python_easy_install/rpy2-2.3.0beta1-py2.7-linux-x86_64.egg/rpy2/rinterface/_rinterface.so:未定义符号:Rf_translateCha rUTF8


I followed the instructions in the website: 我按照网站上的说明进行操作:

1. Installed R with the option for shared libraries: 1.安装了R,带有共享库选项:

# <go to the R source directory>
make distclean
./configure --enable-R-shlib
make
make install

2. Added this to my .bashhrc : 2.将此添加到我的.bashhrc

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$RHOME/lib

3. And then installed rpy2 with easy_install (I also tried with pip ): 3.然后用easy_install安装rpy2 (我也尝试过pip ):

easy_install -d /home/jimmy/.python_easy_install rpy2

Why is it not working? 为什么不起作用?

This is all on Linux with the latest versions of Rpy2 , R and Python . Linux上具有最新版本的Rpy2RPython

This is likely because an older version of R is picked up at runtime. 因为R的旧版本在运行时拿起这是可能的。

I'd think that a better way to set LD_LIBRARY_PATH would be to do: 我认为设置LD_LIBRARY_PATH的更好方法是:

export LD_LIBRARY_PATH=$RHOME/lib:$LD_LIBRARY_PATH

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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