无法在Travis CI上构建python项目

时间:2017-06-10 10:29:25

标签: python travis-ci

我已经安装了pyhash,为什么总是说它无法找到模块?任何人都可以帮助我吗?

这是我的.travis.yml:

language: python
before_install:
    - sudo apt-get -qq update
    - sudo apt-get install libboost-all-dev
python:
    - "2.7"
install:
    - sudo pip install pyhash
script: py.test

这是我的项目目录:

/bloom
    __init__.py
    /src
       __init__.py
       f1.py
       f2.py
    /test
       __init__.py
       test_f1.py
       test_f2.py

错误消息是:

  

ImportError:没有名为pyhash的模块

但我已经看到它安装在cmd窗口中。

1 个答案:

答案 0 :(得分:0)

TL; DR:尝试摆脱所有sudo次调用,使用addon:apt来安装boost需求和pip install --user pyhash(但这对python3.5无效)。

我做了几次测试,如果您使用sudo pip install来安装软件包,那么安装脚本用户就无法看到它。例如,请参阅this travis build。 在我的测试中,sudo: required是否添加到.travis.yml并不重要。

不幸的是without sudo由于pip install pyhash错误,PermissionError: [Errno 13] Permission denied: '/usr/lib/libboost_python.so'是不可能的。

但是我在stackoverflow上也发现了this问题,看起来您可以使用pip install --user代替sudo pip install

我也tested这种方法,不幸的是你不能在我的配置中使用--user。错误是:Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

所以最后我尝试使用apt addon而不是sudo apt-get install来确保sudo:required未被使用,但它也did not help

如果没有尝试为travis-ci创建问题

,也许你会更幸运地使用python2.7
相关问题