我最近在升级matplotlib时遇到了一些问题,所以我最终通过brew在我的Mac (Sierra)上安装了不同版本的Python,然后卸载了它。然而,现在matplotlib可以工作(2.0.2),但每当我运行一个以前可以工作的特定python脚本时,我都会得到一个以前没有的错误:
Traceback (most recent call last):
File "sim.py", line 254, in <module>
main()
File "sim.py", line 118, in main
db = shelve.open('.sim_balance', 'c')
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 243, in open
return DbfilenameShelf(filename, flag, protocol, writeback)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shelve.py", line 227, in __init__
Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/anydbm.py", line 84, in open
mod = __import__(result)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dbhash.py", line 7, in <module>
import bsddb
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py", line 67, in <module>
import _bsddb
ImportError: No module named _bsddb根据我的在线搜索,这与我的brew安装的python干扰有关吗?我昨天还删除了/Library/Python/2.7/site-packages中的所有文件,这可能也是导致这一问题的原因。
我曾经尝试过自制的brew install berkeley-db,但后来pip install bsddb3出现了问题:
Terrys-MBP:site-packages Terry$ pip install bsddb3
Collecting bsddb3
Using cached bsddb3-6.2.4.tar.gz
Complete output from command python setup.py egg_info:
Can't find a local Berkeley DB installation.
(suggestion: try the --berkeley-db=/path/to/bsddb option)
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/m5/1fg5rnj11_9cz5pntlqlwzyc0000gn/T/pip-build-elBAFK/bsddb3/编辑:已解决。安装了anaconda,通过conda install安装了bsddb,现在一切都正常了。
发布于 2017-07-02 08:33:08
解决了。我安装了anaconda,通过conda install安装了bsddb,现在一切都正常了。
https://stackoverflow.com/questions/44829520
复制相似问题