Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4450748
  • 博文数量: 1214
  • 博客积分: 13195
  • 博客等级: 上将
  • 技术积分: 9105
  • 用 户 组: 普通用户
  • 注册时间: 2007-01-19 14:41
个人简介

C++,python,热爱算法和机器学习

文章分类

全部博文(1214)

文章存档

2021年(13)

2020年(49)

2019年(14)

2018年(27)

2017年(69)

2016年(100)

2015年(106)

2014年(240)

2013年(5)

2012年(193)

2011年(155)

2010年(93)

2009年(62)

2008年(51)

2007年(37)

分类: NOSQL

2014-04-14 15:29:42

发现Berkeley DB是单文件的key value 的数据库,目前被Oracle 拥有,使用 AGPL3 commercial license.
ubuntu 下安装libdb5.3-dev;Mac 下安装brew install berkeley-db。python driver 使用 .
由于安装PyBSDDB出现了一些问题,需要设置环境变量(后文详述),于是我决定从源码开始编译。

  1. wget
  2. tar zxvf db-6.0.30.tar.gz -C /opt
  3. cd /opt/db-6.0.30/build_unix
  4. ../dist/configure --prefix=/usr/local/berkeley-db/ --enable-cxx && make
  5. sudo make install

pip install bsddb3 出现错误:

(suggestion: try the --berkeley-db=/path/to/bsddb option)

pip install --berkeley-db=/usr/local/berkeley-db bsddb3 依然出错。

'pip help install'后,使用如下命令,feed it to package's setup.py,可还是这个报错。
pip install --install-option="--berkeley-db=/usr/local/berkeley-db/" bsddb3


这里 详细讲述了这个错误,
指出Mac下可以 brew install berkeley-db --without-java 就不用安装JDK了。
下面是分析:

  1.     Still nothing. If we look at the output, we can see that the install is failing on running 'python setup.py egg_info'. If we go into the build directory and run that manually, it suggests we add the --berkeley-db option. When we do that, it seems to work, but how do we get pip to call it with that option?

  1.     It turns out, we can't. At least, not that I can figure out. You can pass parameters to 'setup.py build' through pip by the --install-option flag, but not the 'setup.py egg_info'. It's just not baked in there. Horrible.

  1.     At this point, our options are, fix pip, or fix the bsddb3 setup.py process. Well, neither are especially appealing options. If I ever need to do this again, or do it on another machine, or whatever, that would be a mess. There's gotta be a better way.

  1.     Thinking back to the 90s (I know, right?), when you tried to build a library that had a dependency on another library, you could specify the location of that dependency through a similar flag, like --my-library-path=/blah. This was almost always a convenience shortcut for setting an environment variable, MY_LIBRARY_PATH=/blah. Let's see if that's the case here. If we go into the egg and grep around for 'berkeley-db', we find the following segment:
if os.name == 'posix':
   # Allow setting the DB dir and additional link flags either in
   # the environment or on the command line.
   # First check the environment...
   BERKELEYDB_INCDIR = os.environ.get('BERKELEYDB_INCDIR''')
   BERKELEYDB_LIBDIR = os.environ.get('BERKELEYDB_LIBDIR''')
   BERKELEYDB_DIR = os.environ.get('BERKELEYDB_DIR''')
   LFLAGS = os.environ.get('LFLAGS', [])
   LIBS = os.environ.get('LIBS', [])

   # ...then the command line.
   # Handle --berkeley-db=[PATH] and --lflags=[FLAGS]
   args = sys.argv[:]
   for arg in args:
       if arg.startswith('--berkeley-db-incdir='):
           BERKELEYDB_INCDIR = arg.split('=')[1]
           sys.argv.remove(arg)
       if arg.startswith('--berkeley-db-libdir='):
           BERKELEYDB_LIBDIR = arg.split('=')[1]
           sys.argv.remove(arg)
       if arg.startswith('--berkeley-db='):
           BERKELEYDB_DIR = arg.split('=')[1]
           sys.argv.remove(arg)


YES_I_HAVE_THE_RIGHT_TO_USE_THIS_BERKELEY_DB_VERSION=1 BERKELEYDB_DIR=/usr/local/berkeley-db/ pip install bsddb3
问题解决


阅读(4240) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

CU博客助理2014-05-22 13:11:18

嘉宾点评:
是博主laoliulaoliu描述了如何在云主机上使用Python包管理器pip安装Berkeley DB的过程,内容比较简单,有一定的参考价值。(感谢您参与“原创博文评选”获奖结果即将公布)