简体   繁体   中英

How to make Python see module installed via apt?

I'm trying to use Travis CI to run tests of my Python code.

My project needs dbus module and it's not available in PyPi, so I have to install it via apt.

Problem is that tests fail with ImportError: No module named 'dbus'. It's quite strange, because I can see in report about successful installation of required packages. Here is my .travis.yml and example of Travis log .

Do I do something wrong?

From the travis log you posted, all your packages are being installed in a virtual environment.

The virtual environment is created in a clean state - so it does not have any links to system libraries, indeed it states so in the documentation :

CI Environment uses separate virtualenv instances for each Python version. System Python is not used and should not be relied on. If you need to install Python packages, do it via pip and not apt.

If you decide to use apt anyway, note that Python system packages only include Python 2.7 libraries on Ubuntu 12.04 LTS. This means that the packages installed from the repositories are not available in other virtualenvs even if you use the –system-site-packages option.

I believe it explains your problem:

  1. virtual environments are isolated and have no link to system packages.
  2. Even if you use apt, it is limited to Python 2.7 , and you are trying to install a python3- package.

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