close

[Solved] ImportError: No module named apt_pkg

Are You Facing the Following error ImportError: No module named apt_pkg in Python? Then You are in right place. In this article, I am going to share how to solve this error. Lets get started with this article.

How To Fix ImportError: No module named apt_pkg Error?

  1. How To Fix ImportError: No module named apt_pkg Error?

    To Fix ImportError: No module named apt_pkg Error First of all run this command in your terminal: cd /usr/lib/python3/dist-packages/ and then run this command: sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so Now, Your error will be solved.

  2. ImportError: No module named apt_pkg

    To Fix ImportError: No module named apt_pkg Error You Just need to reinstall apt_pkg will resolve your error. To reinstall apt_pkg You just need to run the following command in your terminal. Just like this: sudo apt-get install –reinstall python3-apt Just after reinstalling apt_pkg Open the Python dist-packages folder by running this command: cd /usr/lib/python3/dist-packages Now You need to run the following command: sudo ln -s apt_pkg.cpython-[replace-with-your-version]-x86_64-linux-gnu.so apt_pkg.so And Now, Your error must be resolved.

Solution 1: Reinstall apt_pkg

To Fix ImportError: No module named apt_pkg Error You Just need to reinstall apt_pkg will resolve your error. To reinstall apt_pkg You just need to run the following command in your terminal. Just like this.

sudo apt-get install --reinstall python3-apt

Just after reinstalling apt_pkg Open the Python dist-packages folder by running this command.

cd /usr/lib/python3/dist-packages

Now You need to run the following command.

sudo ln -s apt_pkg.cpython-[replace-with-your-version]-x86_64-linux-gnu.so apt_pkg.so

And Now, Your error must be resolved.

Solution 2: Run this Command In Your terminal

You just need to run this command in your terminal.

cd /usr/lib/python3/dist-packages
cp apt_pkg.cpython-34m-i386-linux-gnu.so apt_pkg.so

#OR

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

Solution 3: Follow this

First of all run this command in your terminal.

cd /usr/lib/python3/dist-packages/

and then run this command.

sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so

Now, Your error will be solved.

Solution 4: Remove python3-apt

First Of all, Completly Remove python3-apt. You can use this command.

apt-get remove  python3-apt

Now, You need to reinstall python3-apt

apt-get install python3-apt

Now, Your error must be solved.

Solution 5: Run this command

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

Conclusion

It’s all About this error. I hope We Have solved Your error. Comment below with Your thoughts and your queries. Also, Comment below on which solution worked for you.

Also, Read

Leave a Comment