0

i need help. since 5 days before, i tried to update packages in Mint using this command

sudo apt update

but, at the end of the process, the terminal gives me traceback

Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Reading package lists... Done E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi' E: Sub-process returned an error code

i tried to find the solution to fix this, but i can't. does anyone have a solution?

  • Does this answer your question? [python-dev installation error: ImportError: No module named apt\_pkg](https://stackoverflow.com/questions/13708180/python-dev-installation-error-importerror-no-module-named-apt-pkg) – Mohammad Moallemi Feb 17 '21 at 16:48

2 Answers2

0

If the apt-get also doesn't work, can you try this? Most probably, apt_pkg is not in the correct path.

cd /usr/lib/python3/dist-packages

ls -la /usr/lib/python3/dist-packages

Look for any file of the format apt_pkg.cpython- and so on. Copy that file's name. And replace apt_pkg.cpython-36m-x86_64-linux-gnu.so with the copied file's name in the command below, and hit enter.

sudo cp apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so

Pranjalya
  • 68
  • 2
  • 7
0

I also had the issue with "cp: cannot stat 'apt_pkg.cpython-36m-x86_64-linux-gnu.so': No such file or directory while I was as super user. I did the same command withouth the sudo command and it worked fine. I have in my system python 3.5, 3.6 and 3.7, so I do not think the version of python is a problem.

cp apt_pkg.cpython-36m-x86-64-linux-gnu.so.so apt_pkg.so

I hope this help someone now at 2022 :D

Regards.

Cyberfete
  • 11
  • 3