没有名为“gdbm”的模块

没有名为“gdbm”的模块

我刚刚在我的 Ubuntu 上安装了 python 3.5.1,但是无论我是使用 Anaconda 安装还是使用以下方式安装,都出现了这个错误消息apt-get

No module named 'gdbm'

通常会显示在我的终端上。我还尝试gdbm使用以下方法进行安装:

sudo apt-get install gdbm

但问题并没有解决。有人能帮我解决这个问题吗?

答案1

sudo apt-get install python3.5-gdbm

帮助过我

答案2

就我而言,如果我尝试跑步任何命令在 bash shell 中不存在,我会得到这个严重的错误:

$ 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'

以上答案对我而言都不起作用。虽然这个问题已经解决了,但这可能会对某些人有所帮助。如果您仍然遇到此问题,也许这会有所帮助:

我已经从存储库安装了 python3.6 ppa.launchpad.net/jonathonf/python-3.6/ubuntu,但显然这破坏了一些东西。

当尝试重新安装软件包时command-not-found python3-commandnotfound python3-gdbm python3-gdbm-dbg sessioninstaller,我注意到 apt 正在从这里提取源:

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]

为了修复该问题,我只需删除该存储库:

sed -i ' s/^/#/' /etc/apt/sources.list.d/jonathonf-ubuntu-python-3_6-xenial.list

然后重新运行此命令(以 root 身份):

apt update ; apt purge python3-gdbm ; apt install command-not-found python3-commandnotfound python3-gdbm python3-gdbm-dbg sessioninstaller

现在,一切恢复正常:

$ lol
No command 'lol' found, did you mean:
 Command 'sol' from package 'aisleriot' (main)
 Command 'col' from package 'bsdmainutils' (main)
lol: command not found

答案3

您是否尝试过安装包python3-gdbm

sudo apt-get install python3-gdbm

答案4

我已经安装了 python 3.6 并且可以正常工作,我尝试了很多方法,但是

sudo apt-get install python3.6-gdbm

这个命令对我有用

相关内容