I use Python 3.6 in an anaconda environment. I installed GDBM with
conda install gdbm
The installation went well, however I can't use dbm.gnu from Python:
ModuleNotFoundError: No module named '_gdbm'
It seams that Python doesn't include the _gdbm module, even if GDBM is actually installed.
Is this a known problem? How can I fix it?
Thanks!
I faced this issue as well. This is probably not the ideal way, but it works. I did the following to resolve this -
This installs the gdbm library for python3, however since apt-get and anaconda are two independent package managers; this isn't going to solve your problem. We primarily do this to get a hold of the .so shared library which we will place in the right folder in our anaconda installation. Next we find the location of the .so file using -
This gives us the following output -
The file we require is here -
Copy this file to the lib-dynload folder of your anaconda installation; for me this was -
Note, that this will only work if the directory the
.sowas copied to is in python'ssys.path. To find the correct directory to copy to, assuming you're inside the activated conda environment, run:For example, in my case, the directory was inside the environment path and not in the anaconda main library.
~/anaconda3/envs/myenvname/lib/python3.7/lib-dynloadNow try importing the module in python -
or testing it from the command line:
This should have fixed your problem.
Please note, mine is an Ubuntu-16.06 OS and my python version is 3.5.2. The .so file may work with python3.6 as well, if not you can try installing python3.6-gdbm, although a quick search for ubuntu 16.04 didn't give me any results.