将rpy2与numpy.testing一起使用时的ImportError

时间:2015-04-29 12:49:17

标签: python importerror

使用numpy.testing模块进行单元测试时遇到了一个相当奇怪的错误。我在VM中运行iPython笔记本。在我的代码中,我有一个测试,我将输出与R中的输出进行比较。这要求我像这样加载rpy2模块:

import rpy2.robjects as robjects
from rpy2.robjects.packages import importr
fastclime = importr('fastclime')
grdevices = importr('grDevices')

但是当我运行! py.test时,我收到以下错误:

==================================== ERRORS ========== ==========================

_____________________ ERROR collecting test_fastclime_R.py _____________________
test_fastclime_R.py:6: in <module>
    import rpy2.robjects as robjects
../../anaconda/lib/python2.7/site-packages/rpy2/robjects/__init__.py:15: in <module>
    import rpy2.rinterface as rinterface
../../anaconda/lib/python2.7/site-packages/rpy2/rinterface/__init__.py:101: in <module>
    from rpy2.rinterface._rinterface import *
E   ImportError: /home/bitnami/anaconda/bin/../lib/libreadline.so.6: undefined symbol: PC
====================== 10 passed, 1 error in 0.19 seconds ======================

我怀疑这与某些环境变量没有链接到我的工作目录有关,但我不知道如何修复它。任何建议都非常感谢!谢谢!

1 个答案:

答案 0 :(得分:1)

另一个解决方案是从环境中删除conda的readline并使用pip的一个:

conda remove --force readline
pip install readline