Home > Net >  Linux terminal and Python are mushed together
Linux terminal and Python are mushed together

Time:09-19

When I run some commands, which work, for example neofetch, it gives me a Python error.

username@host:~$ as
Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

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.

CodePudding user response:

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.

CodePudding user response:

try to find which python are you using using which python and uninstall the first python interpreter it finds.

  • Related