How to solve No module named 'apt_pkg' error on Ubuntu 20.04.3 LTS x86_64 [duplicate]

Solution 1:

In all currently supported versions of Ubuntu open the terminal and type:

apt download python3-minimal
sudo apt install --reinstall ./python3-minimal_*.deb
sudo apt install -f

If that doesn't work a simple reboot will sometimes solve this problem.

Solution 2:

This solved my same/similar issue:

cd /usr/lib/python3/dist-packages
ls -la /usr/lib/python3/dist-packages
sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so

Source: Linux Question