macos 如何修复 Mac OS X 10.5 Leopard 上默认 Python 包中损坏的 BSDDB 安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/814041/
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
How to Fix the Broken BSDDB Install in the Default Python Package on Mac OS X 10.5 Leopard?
提问by Noel
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 suggestionor using MacPorts etc?
不错吧?如何在不放弃和安装/配置/维护我自己的 Python 包的情况下按照TMNC 的建议或使用 MacPorts 等解决这个问题?
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.
我的问题仍然存在:为什么默认安装被破坏,是否可以修复它。
回答by Alex Martelli
回答by rhoerbe
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
- 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
- 从 macports 安装 db53
- 下载并解压 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
回答by rafaelvalle
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
/usr/local/lib/python2.7/site-packages/bsddb3
Make sure you backup the bsddb folder just in case.
确保备份 bsddb 文件夹以防万一。
回答by lef
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.sofile 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(此处的说明)
回答by Theo
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 文件,现在它可以完美运行。