No module named APT-PKG

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

Steps to solve the error "No module named APT-PKG"

Method 1 - Install python-apt package

sudo apt-get install python-apt

Method 2 - Reinstall python3-apt package

sudo apt-get python3-apt --reinstall

Method 3 - Properly set .so file location

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

Written by

KarChunT

At

Fri Mar 28 2025