How to Fix the Broken BSDDB Install in the Default

2019-02-18 03:14发布

Do the following on the default Python install on Mac OS X 10.5 (Leopard) w/ Developer Tools:

noel ~ : python

Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bsddb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/bsddb/__init__.py", line 51, in <module>
import _bsddb
ImportError: No module named _bsddb

nice, huh? How do I fix this without giving up and installing/configuring/maintaining my own Python package as per TMNC's suggestion or using MacPorts etc?

Edit

I've gone around the problem by installing Python2.4 and BSDDB via MacPorts.

My question still stands: why is the default install broken and is it possible to fix it.

5条回答
Luminary・发光体
2楼-- · 2019-02-18 03:46

A solution I found was to install ActivePython, dig into its library (located in /Library/Frameworks/Python.framework/Versions/....your version here..../lib) and copy and paste the _bsddb.so file into my OS X 10.6 native python 2.6 install directory (/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/).

That fixed the missing _bsddb issue leaving me with a working version of bsddb in my native python install. Then, I just uninstalled ActivePython (instructions here)

查看更多
甜甜的少女心
3楼-- · 2019-02-18 03:47

This pain persists on OSX 10.8. I could not install bsddb3 using macports py-bsddb3 into a virtualenv. What was very simple and did work is:

  • install db53 from macports
  • download and unpack bsddb3 source (https://pypi.python.org/pypi/bsddb3/6.1.0)
  • sudo python setup.py –berkeley-db-incdir=/opt/local/include/db53 –berkeley-db-libdir=/opt/local/lib/db53 install
查看更多
Melony?
4楼-- · 2019-02-18 03:49

The patch did not work for me and I had to replace the bsddb folder in /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7

with the bsddb3 in:

/usr/local/lib/python2.7/site-packages/bsddb3

Make sure you backup the bsddb folder just in case.

查看更多
唯我独甜
6楼-- · 2019-02-18 04:10

The error I had was "No module named _bsddb". It turn out I didn't need to upgrade my bsddb. I wasusing the .pkl file created in windows. After renaming the pkl file to get it out the way Mac OSX Python recreated a new .pkl.db file and now it works perfectly.

查看更多
登录 后发表回答