简体   繁体   中英

Linux python error when command in terminal not found

I'm running Linux Mint 18.3 with kernel 4.13.0-39-generic. Every time I run a command in a terminal that is not valid or the program is not installed I get a stacktrace of a python error

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'

To answer the first question, yes gdbm is installed:

ii  libgdbm3:amd64                            1.8.3-13.1                                   amd64        GNU dbm database routines (runtime version)
ii  python-gdbm                              2.7.12-1~16.04                            amd64        GNU dbm database support for Python
ii  python3-gdbm:amd64                        3.6.5-3~16.04.york0.2                     amd64       GNU dbm database support for Python 3.x

正如您在错误消息中看到的那样,您缺少模块“ gdbm”,如此处所示:

sudo apt-get install python3.5-gdbm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM