Skip to Content

No module named APT-PKG

Learn how to solve the error "No module named APT-PKG" in Python.

karchunt

Kar Chun Tan

Creator

Metadata

Fri Mar 28 2025

1 min read

114 words

No module named APT-PKG

The error “No module named APT-PKG” typically occurs when the Python APT package is not installed or is improperly configured. This package is essential for interacting with the Advanced Package Tool (APT) system in Debian-based Linux distributions.

Method 1 - Install python-apt package

This is the most straightforward way to resolve the issue, as the apt_pkg module is part of the python-apt package.

sudo apt-get update sudo apt-get install python-apt # or python3-apt for Python 3

Method 2 - Reinstall python3-apt package

This method basically reinstalls the package to ensure all files are correctly placed.

sudo apt-get python3-apt --reinstall

Method 3 - Properly set .so file location

This method involves copying the shared object file to the correct location.

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