安装bsddb包 - python

use*_*830 21 python macos installation package

我是python的新手,当我尝试导入bsdddb时,我收到此消息

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py", line 67, in <module>
    import _bsddb
ImportError: No module named _bsddb
Run Code Online (Sandbox Code Playgroud)

所以我按照这个这个,所以我下载了这个包bsddb3-4.5.0.tar.gz.我想用它做什么,我试图在正确的目录中运行python install setup.py int bsddb3-4.5.0(我使用的是osx).然后我明白了

Can't find a local BerkeleyDB installation.
(suggestion: try the --berkeley-db=/path/to/bsddb option)
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

Fra*_*que 16

bsddb is deprecated since 2.6. The ideal is to use the bsddb3 module.

My suggestion, and by far the easiest option, is to install Homebrew and use it to get BerkeleyDB on your system:

brew install berkeley-db
Run Code Online (Sandbox Code Playgroud)

After this install bsddb3 using pip

pip install bsddb3
Run Code Online (Sandbox Code Playgroud)

or download the source and install normally.

python setup.py install
Run Code Online (Sandbox Code Playgroud)

  • pip install straight对我来说不太有用,我不得不去bsddb3的源目录并做一个python setup.py install --berkeley-db = $(brew --prefix)/berkeley-db/5.3.21 / (8认同)
  • 这对我来说是小牛队使用来自Apple的`python`和来自Homebrew的`pip`和`berkeley-db`(作为root):`BERKELEYDB_DIR = $(brew --cellar)/berkeley-db/5.3.28 pip install bsddb3 `(详见http://chriszf.posthaven.com/getting-berkeleydb-working-with-python-on-osx) (8认同)
  • 2016年更新:`YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION = 1 BERKELEYDB_DIR = $(brew --cellar)/berkeley-db/6.1.26 pip install bsddb3`,这对我有用. (3认同)
  • 2018 年更新:OSX El Capitan 引入了“系统完整性保护”,这意味着 root 不再是“上帝”,一些系统目录根本无法写入。问题:内置python的`pip`尝试写入这些神圣目录之一,因此它不再起作用。所以,首先安装 [homebrew](https://brew.sh/) 并运行:`pip install python`。之后,打开一个新的终端窗口,您可以正常继续:`sudo YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1 BERKELEYDB_DIR=$(brew --cellar)/berkeley-db/6.2.32 pip install bsddb3` (2认同)

bam*_*dan 10

我有一个类似的问题,但没有一个建议对我有用,因为我无法使用AGPL许可证或Oracle的商业Berkeley许可证.

BERKELEYDB_DIR=$(brew --cellar)/berkeley-db/6.1.26 pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.1.1.tar.gz
Complete output from command python setup.py egg_info:
Trying to use the Berkeley DB you specified...
Detected Berkeley DB version 6.1 from db.h

******* COMPILATION ABORTED *******

You are linking a Berkeley DB version licensed under AGPL3 or have a commercial license.

AGPL3 is a strong copyleft license and derivative works must be equivalently licensed.

You have two choices:

  1. If your code is AGPL3 or you have a commercial Berkeley DB license from Oracle, please, define the environment variable 'YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION' to any value, and try to install this python library again.

  2. In any other case, you have to link to a previous version of Berkeley DB. Remove Berlekey DB version 6.x and let this python library try to locate an older version of the Berkeley DB library in your system. Alternatively, you can define the environment variable 'BERKELEYDB_DIR', or 'BERKELEYDB_INCDIR' and 'BERKELEYDB_LIBDIR', with the path of the Berkeley DB you want to use and try to install this python library again.

Sorry for the inconvenience. I am trying to protect you.

More details:

    https://forums.oracle.com/message/11184885
    http://lists.debian.org/debian-legal/2013/07/

******* COMPILATION ABORTED *******
Run Code Online (Sandbox Code Playgroud)

但是,恢复到旧版本修复它.

使用brew安装旧版本的berkeley-db

brew install berkeley-db4

然后按照建议用pip安装bsddb3

pip install bsddb3

然后

BERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/4.8.30 pip install bsddb3

(修改自Stefan Schmidt的评论,以引用较旧的berkeley-db 版本目录)

最后,应用补丁的描述dbhash.py 这里.


sou*_*ine 7

如果您仍想使用最新的Berkeley DB,@ bamdan的答案使用旧版本的Berkeley DB,

  • 我想你的意思是输入`brew install berkeley-db`。另外,这个许可证是怎么回事?我怎么知道我有这个权利? (2认同)