安装 bsddb 包 - python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16003224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing bsddb package - python
提问by user1611830
I am totally new to python and I have this message when I try to import bsdddb
我对 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
So I followed thisand this, so I downloaded this package bsddb3-4.5.0.tar.gz. What am I suppose to do with it, I tried to run python install setup.py int the bsddb3-4.5.0 in the right directory (I am using an osx). Then I get
所以我跟着这个和这个,所以我下载了这个包bsddb3-4.5.0.tar.gz。我想用它做什么,我尝试在正确的目录中运行 python install setup.py int the bsddb3-4.5.0 (我使用的是 osx)。然后我得到
Can't find a local BerkeleyDB installation.
(suggestion: try the --berkeley-db=/path/to/bsddb option)
Some one could help ?
有人可以帮忙吗?
回答by Francisco Roque
bsddb is deprecated since 2.6. The ideal is to use the bsddb3 module.
bsddb自 2.6起已弃用。理想的情况是使用bsddb3 模块。
My suggestion, and by far the easiest option, is to install Homebrewand use it to get BerkeleyDB on your system:
我的建议,也是迄今为止最简单的选择,是安装Homebrew并使用它在您的系统上获取 BerkeleyDB:
brew install berkeley-db
After this install bsddb3 using pip
在此之后使用pip安装 bsddb3
pip install bsddb3
or download the sourceand install normally.
或者下载源码并正常安装。
python setup.py install
回答by bamdan
I had a similar issue but none of the suggestions worked for me as I couldn't use AGPL license or a commercial Berkeley license from Oracle.
我遇到了类似的问题,但没有任何建议对我有用,因为我无法使用 Oracle 的 AGPL 许可证或商业 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 *******
However reverting to an older version fixed it.
但是恢复到旧版本修复了它。
Install the older version of berkeley-db with brew
使用 brew 安装旧版本的 berkeley-db
brew install berkeley-db4
brew install berkeley-db4
Then as suggested install bsddb3 with pip
然后按照建议使用 pip 安装 bsddb3
pip install bsddb3
pip install bsddb3
Then
然后
BERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/4.8.30 pip install bsddb3
BERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/4.8.30 pip install bsddb3
(modified from Stefan Schmidt's comment to reference the older berkeley-db versiondirectory)
(从 Stefan Schmidt 的评论中修改以引用旧的 berkeley-db版本目录)
Finally apply patch to dbhash.py as described here.
最后按此处所述将补丁应用于 dbhash.py 。
回答by soulmachine
@bamdan 's answer uses an older version of Berkeley DB, if you still want to use the latest, Berkeley DB,
@bamdan 的回答使用旧版本的 Berkeley DB,如果您仍想使用最新的 Berkeley DB,
First, install the latest Berkeley DB
pip install berkeley-dbSecond, set an environment variable
YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSIONto indicate that you have the licenseBERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/6.1.26 YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=yes pip install bsddb3
一、安装最新的Berkeley DB
pip install berkeley-db二、设置环境变量
YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION表示你有licenseBERKELEYDB_DIR=$(brew --cellar)/berkeley-db4/6.1.26 YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=yes pip install bsddb3

