Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No module named 'apt' #17

Open
grimsi opened this issue Sep 25, 2022 · 9 comments
Open

No module named 'apt' #17

grimsi opened this issue Sep 25, 2022 · 9 comments

Comments

@grimsi
Copy link

grimsi commented Sep 25, 2022

I have trouble installing the exporter, when I run it I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/pkg-exporter", line 5, in <module>
    from pkg_exporter.textfile import main
  File "/usr/local/lib/python3.10/site-packages/pkg_exporter/textfile.py", line 4, in <module>
    from pkg_exporter.pkgmanager import apt
  File "/usr/local/lib/python3.10/site-packages/pkg_exporter/pkgmanager/apt.py", line 1, in <module>
    import apt
ModuleNotFoundError: No module named 'apt'

Here are the steps I used to install the exporter on Debian:

  1. Install python3-apt: sudp apt-get update && sudo apt-get install -y python3-apt
  2. Install the exporter: pip3 install git+https://github.com/margau/pkg-exporter
  3. Run the exporter: pkg-exporter

I confirmed this by using a fresh docker image (python:slim-bullseye) to run the importer inside of it

@pastukhov
Copy link

Same for me

@pastukhov
Copy link

Finaly get this working inside docker. See my fork https://github.com/pastukhov/pkg-exporter

@pastukhov
Copy link

docker run -it -v /etc:/etc:ro -v /var/lib:/var/lib:ro -v /var/cache:/var/cache:ro  pkg-exporter bash

@boagg
Copy link

boagg commented Sep 21, 2023

Hi,

The error is still present. Are there any updates planned to correct this error?

@margau
Copy link
Owner

margau commented Sep 21, 2023

How did you install it? (venv, pipx etc.) under which os? For debian 12, i added install hints to the readme.

@boagg
Copy link

boagg commented Sep 21, 2023

Thank's for the quick reply

I tested on a debian 11 and installed via pip

@margau
Copy link
Owner

margau commented Sep 21, 2023

In general, the system apt package python3-apt needs to be installed, and the python env needs access to the system libs.

Under bullseye, this worked with the system pip for me. Bookworm disabled global pip usage, i'd recommend pipx here (should also work under bullseye).

Can you paste the install and the executed commands?

@boagg
Copy link

boagg commented Sep 21, 2023

To make it simpler, here is a KO dockerfile (whether with bullseye or bookworm):

FROM python:3.9.18-bullseye

RUN apt-get update && apt-get install python3-apt git -y

RUN pip install pipx

RUN cat /etc/debian_version

RUN pipx run --system-site-packages pkg-exporter

I still get the error:

ModuleNotFoundError: No module named 'apt'

Whatever OS.

@margau
Copy link
Owner

margau commented Sep 22, 2023

I've got it working with the following dockerfile:

FROM debian:bullseye

RUN apt-get update && apt-get install python3-apt git python3-pip python3-venv -y

RUN pip3 install pipx

RUN pipx run --system-site-packages pkg-exporter

Not really sure yet why the inclusion of site packages is not working in your variant though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants