Fixed: modulenotfounderror: no module named apt_pkg

If you are getting this error, that means that the package/module is not installed on your system. The error itself says that.

But as you have landed on this blog that means you are getting this error even though the package is installed on your machine.

In general, we can uninstall and re-install the package. If you are running multiple versions of the same package/module, then uninstall and reinstall the necessary version.

Many people raised their hands that they got modulenotfounderror: no module named apt_pkg this error while dealing with Python.

Learn how to fix this error:

Make sure Python-apt is installed. We should consider removing and reinstalling Python3-apt. You can try:

sudo apt install python3-apt --fix-missing

sudo apt remove python3-apt
sudo apt autoremove
sudo apt autoclean
sudo apt install python3-apt

Perhaps the following code is a better option than the previous one for removing Python3-apt:

sudo apt remove --purge python3-apt

Feel free to use apt-get instead of apt. We hope this is helpful and this is what you were looking for.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top