Thursday, May 26, 2022

[SOLVED] Eror while updating packages from terminal in linux mint

Issue

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?


Solution

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



Answered By - Pranjalya
Answer Checked By - Terry (WPSolving Volunteer)