[Python] How to fix 'ModuleNotFoundError: No module named 'apt_pkg'?

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm running code sudo apt update and fetch error


    ModuleNotFoundError: No module named 'apt_pkg'.
    ​

    Please, help me solve it.

    sudo apt update


    Hit:20 http://ppa.launchpad.net/xorg-edgers/ppa/ubuntu bionic InRelease
    Fetched 93,3 kB in 2s (42,4 kB/s)
    Traceback (most recent call last):
    File "/usr/lib/cnf-update-db", line 8, in <module>
    from CommandNotFound.db.creator import DbCreator
    File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in <module>
    import apt_pkg
    ModuleNotFoundError: No module named 'apt_pkg'
    Reading package lists... Done
    E: Problem executing scripts APT::Update::post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
    E: Sub-process returned an error code

    Continue reading...

Compartilhe esta Página