2017-06-29 183 views
0

我最近升級matplotlib時出現了一些問題,所以我最終通過brew在我的Mac(Sierra)上安裝了不同版本的Python,然後卸載。不過,現在matplotlib作品(2.0.2),但每當我跑過去運行的特定Python腳本,我得到我以前是沒有的錯誤:ImportError:沒有名爲_bsddb的模塊

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,現在一切正常。

+1

你應該用EDIT回答你自己的問題。它有助於維護問題答案的格式。 – akshaynagpal

+0

此外,如果您不知道,您可以接受您自己的答案。 – McGlothlin

+0

顯然我的答案不符合質量要求。那是什麼意思? – TZJ21

回答

0

已解決。我安裝了anaconda,通過conda安裝安裝了bsddb,現在一切正常。

相關問題