python - 使用 python3.9 的 gdbm 无法打开使用 python 3.6 的 gdbm 创建的文件

标签 python python-3.x python-3.9 gdbm

我从 python 3.6 升级到 python 3.9,现在无法读取现有的 gdbm 文件。抛出以下错误,有什么办法解决这个问题吗?

平台:CentOS Linux 版本 7.9.2009(核心)

Python:3.9.9

使用 Python 3.6 版本,我首先使用如下方式创建了文件:

self.def_id_seq_map_db = dbm.open(str(self.datapath / "def_id_seq_map"), 'c')
        self.def_id_seq_map = shelve.Shelf(self.def_id_seq_map_db)

当我尝试使用Python 3.9读取时出现错误:

  File "/usr/local/lib/python3.9/dbm/__init__.py", line 91, in open
    raise error[0]("db type is {0}, but the module is not "
dbm.error: db type is dbm.gnu, but the module is not available

最佳答案

看来您是从源代码安装的 Python。您的系统上可能没有安装 gdbm-devel。

我会尝试什么:

  • 安装 gdbm-devel 并使用 ./configure --enable-optimizations &&\make install 配置/安装 python
  • 如果不起作用,请在 ./configure 脚本中添加以下修饰符:--with-dbmliborder=gdbm:ndbm

关于python - 使用 python3.9 的 gdbm 无法打开使用 python 3.6 的 gdbm 创建的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70755659/

相关文章:

javascript - JavaScript 是否支持像 Python 一样的数组/列表解析?

python - 同时单击包含选项和命令的组

Python - 转换错误

python - 如何在 Vim YCM 中将 Python 自动完成更改为 Venv 目录

python - 错误: [Errno 13] Permission denied: './configure' when use pip3 install matplotlib on termux

python - python中的不可继承方法

python - 检查数据框中的列是否处于纪元时间会给出不同的结果

python - 具有标准 Tensorflow 的 Tensorflow Lite 模型

python - 如何使用 MySQL Connector/Python 调用存储函数?

python - Odoo 10 : Catch the UserError and show it to webpage