简体   繁体   English

"Python:如何为 dbm.gnu 安装 gdbm"

[英]Python: How to Install gdbm for dbm.gnu

In the Python 3 docs, it states that the dbm module will use gdbm if it's installed.在 Python 3 文档中,它声明如果安装了 dbm 模块,它将使用 gdbm。 In my script I use from dbm.gnu import open as dbm_open<\/code> to try and import the module.在我的脚本中,我使用from dbm.gnu import open as dbm_open<\/code>来尝试导入模块。 It always returns with the exception ImportError: No module named '_gdbm'<\/code> .它总是返回ImportError: No module named '_gdbm'<\/code>异常。 I've gone to the gnu website and have downloaded the latest version.我已经访问了 gnu 网站并下载了最新版本。 I installed it using .\/configure --enable-libgdbm-compat<\/code> , make; make check; make install<\/code>我使用.\/configure --enable-libgdbm-compat<\/code>安装它, make; make check; make install<\/code> make; make check; make install<\/code> make; make check; make install<\/code> , and it installed with no errors. make; make check; make install<\/code> ,它安装没有错误。 I can access the man page for the library but I still can't import it into Python 3.5.2 (Anaconda).我可以访问该库的手册页,但仍然无法将其导入 Python 3.5.2 (Anaconda)。 How do I install the Python module for gdbm?如何为 gdbm 安装 Python 模块?

"

I got similar issue though I am not sure which platform you are using.尽管我不确定您使用的是哪个平台,但我遇到了类似的问题。

Steps are:步骤是:

  1. look for file _gdbm.cpython-"python version"-.so example file: _gdbm.cpython-39-darwin.so查找文件 _gdbm.cpython-“python 版本”-.so 示例文件:_gdbm.cpython-39-darwin.so
  2. Once you find the path check which python version in directory path.找到路径后,检查目录路径中的哪个 python 版本。
  3. Try creating same python venv.尝试创建相同的 python venv。
  4. Execute your code.执行你的代码。

Before this make sure you have install appropriate gdbm version installed on host machine, for mac it's different for ubuntu it's different name.在此之前,请确保您已在主机上安装了适当的 gdbm 版本,对于 mac,它与 ubuntu 不同,它的名称不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM