Nel mio caso, se provassi a eseguire qualsiasi comando che non esiste in una shell bash otterrei questo grosso errore:
$ programthatdoesntexist
Traceback (most recent call last):
File "/usr/lib/python3.5/dbm/gnu.py", line 4, in <module>
from _gdbm import *
ImportError: No module named '_gdbm'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 7, in <module>
import dbm.gnu as gdbm
File "/usr/lib/python3.5/dbm/gnu.py", line 6, in <module>
raise ImportError(str(msg) + ', please install the python3-gdbm package')
ImportError: No module named '_gdbm', please install the python3-gdbm package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
File "/usr/lib/python3/dist-packages/CommandNotFound/__init__.py", line 3, in <module>
from CommandNotFound.CommandNotFound import CommandNotFound
File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 9, in <module>
import gdbm
ImportError: No module named 'gdbm'
Nessuna delle risposte sopra ha funzionato nel mio caso. Sebbene questo problema sia stato risolto, ciò potrebbe aiutare qualcuno. Se hai ancora questo problema, forse questo ti aiuterà:
Avevo installato python3.6 dal repository ppa.launchpad.net/jonathonf/python-3.6/ubuntu
, e apparentemente ciò ha rotto alcune cose.
Quando command-not-found python3-commandnotfound python3-gdbm python3-gdbm-dbg sessioninstaller
ho provato a reinstallare i pacchetti , ho notato che apt stava estraendo le fonti da qui:
Get:1 http://ppa.launchpad.net/jonathonf/python-3.6/ubuntu xenial/main amd64 python3-gdbm amd64 3.6.5-3~16.04.york0.2 [14.6 kB]
Per risolvere il problema, ho semplicemente rimosso quel repository:
sed -i ' s/^/#/' /etc/apt/sources.list.d/jonathonf-ubuntu-python-3_6-xenial.list
E poi riesegui questo comando (come root):
apt update ; apt purge python3-gdbm ; apt install command-not-found python3-commandnotfound python3-gdbm python3-gdbm-dbg sessioninstaller
Ora tutto funziona di nuovo:
$ lol
No command 'lol' found, did you mean:
Command 'sol' from package 'aisleriot' (main)
Command 'col' from package 'bsdmainutils' (main)
lol: command not found