帮酷LOGO
0 0 评论
文章标签:模块  python3  Named  

问题

我刚刚在我的Ubuntu上安装了python 3.5.1,但是得到了这个错误信息,无论我用Anaconda还是用apt-get安装:


No module named 'gdbm'



我还尝试使用以下方法安装gdbm


sudo apt-get install gdbm



但是不能解决这个问题。


回答1

在我的情况下,如果我尝试运行任何在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




回答2

你是否尝试安装软件包python3-gdbm


sudo apt-get install python3-gdbm




回答3


sudo apt-get install python3.6-gdbm



此命令为我工作


回答4

我遇到了同样的问题,并通过以下方法解决了问题:


sudo apt install python3-gdbm=3.5.1-1


dpkg -L python3-gdbm



现在我得到了同样的问题。

所以,在最新版本的python3-gdbm中显然存在错误(bug)。




文章标签:模块  Named  python3  

Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语