gpt4 book ai didi

python - 特拉维斯 CI : error when installing rpy2

转载 作者:行者123 更新时间:2023-11-28 16:27:46 28 4
gpt4 key购买 nike

我正在开发一个依赖于 rpy2 的 python 包。我想用 Travis CI 运行测试。在 .travis.yml 中,我安装了 conda 并使用 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中:

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",
],
)

当 Travis CI 安装我的包时,出现以下错误:

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.

请问有大佬知道怎么解决吗?我尝试在 .travis.yml 中安装 r:

addons:
apt:
packages:
- r

但是,它并没有改变错误信息...

编辑: 在评论中有人指出,我需要在 addons.apt.sources 中至少指定一个源,以便 APT 插件工作,R 包是命名为 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

然而,在我的笔记本电脑上它工作正常!所以我猜问题还是rpy2没有安装好

最佳答案

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

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

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

的 python 脚本时
import rpy2.robjects

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

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

import readline
import rpy2.robjects

关于python - 特拉维斯 CI : error when installing rpy2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35020311/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com