简体   繁体   中英

Failed to build python project on Travis CI

I've pyhash installed already, why does it always say that it can't find the module? Can anyone help me?

here is my .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

And this is my project directory:

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

The error message is:

ImportError: No module named pyhash

But I've seen it installed in the cmd window.

TL;DR: Try getting rid of all sudo calls, use addon:apt to install boost requirements and pip install --user pyhash (however that didn't help with python3.5).

I did several tests and it looks like if you use sudo pip install for installing package it then is not visible by your install script user. See this travis build for example. In my tests it did't matter if sudo: required was added to .travis.yml or not.

Unfortunatelly without sudo it is impossible to pip install pyhash , because of PermissionError: [Errno 13] Permission denied: '/usr/lib/libboost_python.so' error.

However I also found this question on stackoverflow and it looks like you can use pip install --user instead of sudo pip install .

I also tested this approach and unfortunatelly you can't use --user in my configuration. Error was: Can not perform a '--user' install. User site-packages are not visible in this virtualenv. Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

So finally I tried to use apt addon instead of sudo apt-get install to make sure sudo:required is not used but it also did not help .

Maybe you would have more luck with python2.7, if no try creating issue for travis-ci

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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