python-3.x - 在 macOS 上为 Python 3.6.3 使用 dbm.gnu

标签 python-3.x gnu dbm

我正在尝试打开 .db db.gnu 类型的文件.尝试使用内置 Python 3 模块打开它 dbm失败并显示以下消息:

dbm.error: db type is dbm.gnu, but the module is not available

我知道我必须使用 gnu dbm 中的子模块打开这个。但是,我无法在 macOS 上的 Python 3.6.3 中这样做:
In [1]: import dbm
In [2]: dbm.gnu
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-ddbd370a1085> in <module>()
----> 1 dbm.gnu

AttributeError: module 'dbm' has no attribute 'gnu'

如何使用 dbm.gnu在 Mac 上?

最佳答案

我已经在 pyenv 中安装了 3.6.4,所以我必须执行以下操作:

brew install gdbm

然后在那之后,我需要重新安装 3.6.4。
pyenv uninstall 3.6.4
pyenv install 3.6.4
pyenv global 3.6.4

在此之后,它按预期工作。

关于python-3.x - 在 macOS 上为 Python 3.6.3 使用 dbm.gnu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48676678/

相关文章:

python - 与 anydbm 相比,带有 Python 的 sqlite 慢得不合理

python-3.x - 无法将 EventBridge 计划附加到 AWS SAM 中的 Lambda 函数

python - 如何从字典中返回值列表?

c++ - 从目标文件列表 (*.o) 构建库 (lib.a) 的 makefile

parallel-processing - GNU 并行根本不工作

python - Python的搁置模块是否使用内存映射IO?

python - 2 个 csv 文件之间的循环在第一马赫处停止

python - 在请求中设置端口

linux - 如何识别文件中以 5 结尾的行

.net - NET有DBM吗?