如何修复 Mac OS X 10.5 Leopard 上默认 Python 包中损坏的 BSDDB 安装?
使用开发人员工具在 Mac OS X 10.5 (Leopard) 上的默认 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
不错吧? 如何解决这个问题而不放弃并按照 TMNC 的建议 或使用 MacPorts 等?
编辑
我通过 MacPorts 安装 Python2.4 和 BSDDB 解决了这个问题。
我的问题仍然存在:为什么默认安装被破坏以及是否可以修复它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
请按照 http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-bsddb-modules-to-work/ 。
Follow the instructions at http://marc-abramowitz.com/archives/2007/11/28/hacking-os-xs-python-dbhash-and-bsddb-modules-to-work/ .
该补丁对我不起作用,我不得不替换 bsddb 文件夹
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7
与 bsddb3 位于:
/usr/local/lib/python2.7/site-packages/bsddb3
确保备份 bsddb 文件夹就在案件。
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.
这种痛苦在 OSX 10.8 上仍然存在。 我无法使用 macports py-bsddb3 将 bsddb3 安装到 virtualenv 中。 非常简单且有效的是:
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:
我找到的一个解决方案是安装 ActivePython,深入了解它的库(位于 /Library/Frameworks/Python.framework/Versions/....您的版本在这里..../lib)并复制并粘贴 _bsddb .so 文件放入我的 OS X 10.6 本机 python 2.6 安装目录 (/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/)。
这解决了缺少 _bsddb 的问题,让我在本机 python 安装中获得了 bsddb 的工作版本。 然后,我刚刚卸载了 ActivePython(此处的说明)
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)
我遇到的错误是“没有名为 _bsddb 的模块”。 事实证明我不需要升级我的 bsddb。 我正在使用在 Windows 中创建的 .pkl 文件。 重命名 pkl 文件以将其删除后,Mac OSX Python 重新创建了一个新的 .pkl.db 文件,现在它可以完美运行。
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.