Score:0

commands which dont exist refer to python instead of apt suggestion

de flag

I had some issues when installing a newer version of python on my ubuntu installation. Having downloaded a few different versions i then changed some soft links including repointing python to the 3.8 version as well as pip to pip3.

Now my issue is that when ever i type something that normally I would get an apt suggestion for or expect to a command not found error i now get a python error

Example from working VM which i didnt mess with

ubuntu@vps-f116ed9f:/usr/bin$ wer

Command 'wer' not found, did you mean:

  command 'we' from deb xwpe (1.5.30a-2.1build3)
  command 'ner' from deb frog (0.15-1build2)

Try: sudo apt install <deb name>

ubuntu@vps-f116ed9f:/usr/bin$ lskdflskdf
lskdflskdf: command not found

Example from the VM i changed python and softlink

myuser@myhost:/usr/bin$ wer
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'


myuser@myhost:/usr/bin$ lkjsdfkljsdf
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'

Does anyone know what i can do to fix it so that i will get apt suggestions or "command not found" messages again?

Michael Hampton avatar
cz flag
Undo your changes.
djdomi avatar
za flag
@MichaelHampton lol, sudo apt-get install --reinstall command-not-found but truely, seems to nuked the python installations
Score:0
cn flag

Undo your changes. The suggested packages imply Ubuntu 20.04, but Focal already has a python3 package at 3.8. I do not know what you did to get in this state.

Find the deb package containing Python module apt_pkg, the python3 version.

apt-file search apt_pkg

Reinstall apt_pkg to ensure Python apt bindings exist.

apt reinstall python3-apt
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.