Skip to content

No module named APT-PKG

This error occurs when the apt_pkg module is not found in the Python environment. This module is part of the python-apt package, which is not installed by default in some Python environments.

Method 1 - Install python-apt package

Bash
sudo apt-get install python-apt

Method 2 - Reinstall python3-apt package

Bash
sudo apt-get python3-apt --reinstall

Method 3 - Properly set .so file location

Bash
cd /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-310-x86_64-linux-gnu.so apt_pkg.so