如何在Mac OS X 10.5 Leopard上的默认Python包中修复损坏的BSDDB安装?

时间:2022-05-06 07:15:29

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

在Mac OS X 10.5(Leopard)w / Developer Tools上的默认Python安装上执行以下操作:

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?

很好,对吧?根据TMNC的建议或使用MacPorts等,如何在不放弃和安装/配置/维护我自己的Python软件包的情况下解决这个问题?

Edit

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

我通过MacPorts安装Python2.4和BSDDB解决了这个问题。

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

我的问题仍然存在:为什么默认安装被破坏并且可以修复它。

5 个解决方案

#1


Follow the instructions at http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-bsddb-modules-to-work/ .

按照http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-bsddb-modules-to-work/上的说明进行操作。

#2


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:

这种痛苦持续存在于OSX 10.8上。我无法使用macports py-bsddb3将bsddb3安装到virtualenv中。什么是非常简单和工作是:

  • install db53 from macports
  • 从macports安装db53

  • download and unpack bsddb3 source (https://pypi.python.org/pypi/bsddb3/6.1.0)
  • 下载并解压缩bsddb3源码(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
  • sudo python setup.py -berkeley-db-incdir = / opt / local / include / db53 -berkeley-db-libdir = / opt / local / lib / db53 install

#3


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

该补丁对我不起作用,我不得不替换/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7中的bsddb文件夹

with the bsddb3 in:

使用bsddb3:

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

Make sure you backup the bsddb folder just in case.

请确保备份bsddb文件夹以防万一。

#4


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/).

我找到的解决方案是安装ActivePython,深入其库(位于/Library/Frameworks/Python.framework/Versions/....your version here .... / lib)并复制并粘贴_bsddb.so文件进入我的OS X 10.6本机python 2.6安装目录(/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)

修复了丢失的_bsddb问题,让我在我的本机python安装中使用了bsddb的工作版本。然后,我刚刚卸载了ActivePython(这里的说明)

#5


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.

我遇到的错误是“没有名为_bsddb的模块”。结果我不需要升级我的bsddb。我在使用在Windows中创建的.pkl文件。重命名pkl文件后,Mac OSX Python重新创建了一个新的.pkl.db文件,现在它完美运行。

#1


Follow the instructions at http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-bsddb-modules-to-work/ .

按照http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-bsddb-modules-to-work/上的说明进行操作。

#2


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:

这种痛苦持续存在于OSX 10.8上。我无法使用macports py-bsddb3将bsddb3安装到virtualenv中。什么是非常简单和工作是:

  • install db53 from macports
  • 从macports安装db53

  • download and unpack bsddb3 source (https://pypi.python.org/pypi/bsddb3/6.1.0)
  • 下载并解压缩bsddb3源码(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
  • sudo python setup.py -berkeley-db-incdir = / opt / local / include / db53 -berkeley-db-libdir = / opt / local / lib / db53 install

#3


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

该补丁对我不起作用,我不得不替换/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7中的bsddb文件夹

with the bsddb3 in:

使用bsddb3:

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

Make sure you backup the bsddb folder just in case.

请确保备份bsddb文件夹以防万一。

#4


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/).

我找到的解决方案是安装ActivePython,深入其库(位于/Library/Frameworks/Python.framework/Versions/....your version here .... / lib)并复制并粘贴_bsddb.so文件进入我的OS X 10.6本机python 2.6安装目录(/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)

修复了丢失的_bsddb问题,让我在我的本机python安装中使用了bsddb的工作版本。然后,我刚刚卸载了ActivePython(这里的说明)

#5


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.

我遇到的错误是“没有名为_bsddb的模块”。结果我不需要升级我的bsddb。我在使用在Windows中创建的.pkl文件。重命名pkl文件后,Mac OSX Python重新创建了一个新的.pkl.db文件,现在它完美运行。