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.
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With