error: db type is dbm.gnu, but the module is not available in windows
Asked Answered
A

2

14

I installed python3.6 in windows machine. And get below error while open my.db file.

my.db file created by my program in ubuntu16.04 in python3.6, using shelve module.

In [1]: import shelve

In [2]: db = shelve.open("etc/my.db")
---------------------------------------------------------------------------
error                                    Traceback (most recent call last)
<ipython-input-2-b4828c8ee6e1> in <module>()
----> 1 db = shelve.open("etc/my.db")

c:\Python36\Lib\shelve.py in open(filename, flag, protocol, writeback)
    241     """
    242
--> 243     return DbfilenameShelf(filename, flag, protocol, writeback)

c:\Python36\Lib\shelve.py in __init__(self, filename, flag, protocol, writeback)
    225     def __init__(self, filename, flag='c', protocol=None, writeback=False):
    226         import dbm
--> 227         Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
    228
    229

c:\Python36\Lib\dbm\__init__.py in open(file, flag, mode)
     89     elif result not in _modules:
     90         raise error[0]("db type is {0}, but the module is not "
---> 91                        "available".format(result))
     92     else:
     93         mod = _modules[result]

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

Please help, how can I install a missing module in windows.

Anticipation answered 23/6, 2018 at 7:8 Comment(4)
any fix to share?Doggo
Not yet. Issue occur only when file created by unix and you try to open in windows. If you creating new file, it is working. But it is not creating file with ".db" extension.Anticipation
Try to delete pycache folderUnpolled
I also encounter this issue when I try to read a .db file on WIndows, the file was created on Linux.Azral
S
1

As mentioned by @alexander-p , the problem might be the __pycache__ folders in your source code.

In my case was that I did replace a venv folder with a virtual environment by a new folder with the same name but a newer version of Python (~3.8~ → 3.9), and using at the same time PyCharm (that used the venv setup).

Deleting all the Python caches (and restarting PyCharm just in case) solved the problem.

You can do so with:

$ find . -name __pycache__ | xargs rm -Rv

If the venv folder is inside the same folder where your source code is placed, better to execute:

$ find . -name __pycache__ | grep -v venv | xargs rm -Rv

So the cache inside the venv/ folder is not deleted.

Skillern answered 24/1, 2022 at 18:53 Comment(0)
C
1

The only way I found to fix this error was to install a missing component on my Ubuntu after the upgrade to python3.10

sudo apt-get install python3.10-gdbm
Churr answered 15/6, 2023 at 9:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.