Travis CI:安装rpy2时出错

时间:2016-01-26 17:42:05

标签: python r travis-ci rpy2

我正在开发一个依赖于with open('Criteria.txt') as criteria for criteria_line in criteria: #print (criteria_line) #for debugging criteria_myline = criteria_line.strip().split(',') print ("Assignment Type: "+criteria_myline[0]) print ("Number: "+ criteria_myline [1]) print ("Points: "+ criteria_myline [2]) print ("Weight: "+ criteria_myline [3]) print () 的python包。我想用Travis CI进行测试。在rpy2中,我安装了conda并使用.travis.yml运行测试:

green

language: python # Be strict when checking our package warnings_are_errors: true # command to install dependencies install: # http://conda.pydata.org/docs/travis.html - wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh; - bash miniconda.sh -b -p $HOME/miniconda - export PATH="$HOME/miniconda/bin:$PATH" - hash -r - conda config --set always_yes yes --set changeps1 no - conda update -q conda # Useful for debugging any issues with conda - conda info -a # Replace dep1 dep2 ... with your dependencies - conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy matplotlib pandas cython - source activate test-environment - python setup.py install # command to run tests script: - green ...

setup.py

当Travis CI安装我的软件包时,我收到以下错误:

from setuptools import setup, find_packages

setup(
    version="0.0.0",
    name="...",
    packages=find_packages(),
    install_requires=[
        ...
        "green>=2.0.7",
        "rpy2>=2.7.7",
    ],
)

我想知道是否有人知道如何解决它?我尝试在Installed /home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/tubtrack-0.0.0-py2.7.egg Processing dependencies for tubtrack==0.0.0 Searching for rpy2>=2.7.7 Reading https://pypi.python.org/simple/rpy2/ Best match: rpy2 2.7.7 Downloading https://pypi.python.org/packages/source/r/rpy2/rpy2-2.7.7.tar.gz#md5=be93432426744cdae8a0e5d2b157d371 Processing rpy2-2.7.7.tar.gz Writing /tmp/easy_install-CF50ds/rpy2-2.7.7/setup.cfg Running rpy2-2.7.7/setup.py -q bdist_egg --dist-dir /tmp/easy_install-CF50ds/rpy2-2.7.7/egg-dist-tmp-TTJjtB error: Setup script exited with Error: Tried to guess R's HOME but no command (R) in the PATH. 中安装r:

.travis.yml

但是,它没有更改错误消息...

编辑:在评论中指出,我需要在addons: apt: packages: - r 中指定至少一个来源,以便APT插件正常工作,R包名为addons.apt.sources。我在r-base中进行了以下修改:

.travis.yml

现在似乎addons: apt: sources: - r-packages-precise packages: - r-base 可以找到rpy2,但在使用R运行测试时导入时仍然出现错误:

green

然而,在我的笔记本电脑上工作正常!所以我想问题仍然是Traceback (most recent call last): File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/green-2.2.0-py2.7.egg/green/loader.py", line 212, in loadFromModuleFilename __import__(dotted_module) File "xxx/xxx/xxx.py", line 4, in <module> from .. import tools File "xxx/tools.py", line 5, in <module> import rpy2.robjects as robjects File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/rpy2-2.7.7-py2.7-linux-x86_64.egg/rpy2/robjects/__init__.py", line 15, in <module> import rpy2.rinterface as rinterface File "/home/travis/miniconda/envs/test-environment/lib/python2.7/site-packages/rpy2-2.7.7-py2.7-linux-x86_64.egg/rpy2/rinterface/__init__.py", line 99, in <module> from rpy2.rinterface._rinterface import * ImportError: /home/travis/miniconda/envs/test-environment/lib/libreadline.so.6: undefined symbol: PC 未正确安装。

1 个答案:

答案 0 :(得分:3)

错误ImportError: /home/travis/miniconda/envs/test-environment/lib/libreadline.so.6: undefined symbol: PC实际上是由于conda安装了readline。

Github issue有关于此问题的更多详细信息。

我已验证的解决方法是添加import readline。当我的script on .travis.yml调用只有

的python脚本时
import rpy2.robjects

我得到了相同的ImportError: /home/travis/miniconda/envs/test-environment/lib/libreadline.so.6: undefined symbol: PC错误。

当我使用下面的代码时,我的构建变为绿色。

import readline
import rpy2.robjects