This Content is from Stack Overflow. Question asked by justanormaluser
When I run some commands, which work, for example neofetch, it gives me a Python error.
Traceback (most recent call last):
File “/usr/lib/command-not-found”, line 28, in
from CommandNotFound import CommandNotFound
File “/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py”, line 19, in
from CommandNotFound.db.db import SqliteDatabase
File “/usr/lib/python3/dist-packages/CommandNotFound/db/db.py”, line 5, in
ModuleNotFoundError: No module named ‘apt_pkg’
(I tried to use the code block but it didn’t do anything so I removed them)
It does that whenever I type an invalid command. This started happening after I installed Python 3.9. I am running Kubuntu with Python 3.10 installed by default.
Modern Linux distributions tend to use a lot of python scripts for internal use; for this reason python gets installed with a plethora of libraries.
The error you are getting is because you replaced that fairly complete system python with a version of your own choosing without providing all the libraries the original came with.
The error you see is emitted by
/usr/lib/command-not-found, a script using
python3 as found in the system path.
I strongly recommend that you re-install the original python packages and use e.g.
anaconda for your specific python needs.
The main takeaway from this is:
DON’T MESS WITH THE SYSTEM PYTHON.
This Question was asked in StackOverflow by justanormaluser and Answered by tink It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.