How to make Python see a module installed via apt?

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

My project needs a dbus module and it is not available in PyPi, so I have to install it with apt.

The problem is that the tests fail with ImportError: there is no module named 'dbus'. This is rather strange, because I can see in the report on the successful installation of the necessary packages. Here is my .travis.yml and example Travis magazine .

Am I doing something wrong?

+5
source share
1 answer

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

The virtual environment is created in a clean state - therefore, it does not have any links to system libraries, it is really indicated in the documentation

CI Environment uses separate virtualenv instances for each Python version. The Python system is not used and cannot 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 only Python system packages include the Python 2.7 libraries on Ubuntu 12.04 LTS. This means that packages installed from repositories are not available in other virtualenvs, even if you use the -system-site-packages option.

I believe this explains your problem:

  • virtual environments are isolated and do not have links to system packages.
  • Even if you use apt, it is limited to Python 2.7 and you are trying to install the python3- package.
+2
source

Source: https://habr.com/ru/post/1233500/


All Articles