无法创建 Python 3.5 虚拟环境 ImportError:没有名为“gdbm”的模块

无法创建 Python 3.5 虚拟环境 ImportError:没有名为“gdbm”的模块

我遇到了与此人相同的问题,但不幸的是,切换回 Python 3.4 对我来说不是一个选择,我需要运行 3.5。

我已经破坏了未找到命令?

这是我正在尝试的

mkvirtualenv --python=/usr/local/bin/python3 test_env

输出:

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'

答案1

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

sudo apt-get install python3.6-gdbm

这个命令对我的 Python 3.5 有用,你应该使用

sudo apt-get install python3.5-gdbm

相关内容