找不到终端中的命令时发生Linux python错误

时间:2018-05-16 08:35:15

标签: python linuxmint

我正在使用内核4.13.0-39-generic运行Linux Mint 18.3。 每次我在一个无效的终端中运行一个命令或者没有安装该程序时,我得到一个python错误的堆栈跟踪

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'

要回答第一个问题,是安装了gdbm:

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

1 个答案:

答案 0 :(得分:0)

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

sudo apt-get install python3.5-gdbm