pythonpython-3.xpython-3.9gdbm

gdbm with python3.9 unable to open a file created by gdbm with python 3.6


I upgraded from python 3.6 to python 3.9 and now the existing gdbm file is not getting read. Following error is being thrown, is there any way to fix this?

Platform: CentOS Linux release 7.9.2009 (Core)

Python: 3.9.9

With Python 3.6 version I created the file in the first place using like this:

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)

The error when I try to read with 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

Solution

  • It seems you installed Python from sources. You may not have gdbm-devel installed on your system.

    What I would try: