Mac最新系统bssdb BUG

这个bug在Mac OS更新到10.14时候出现,当前系统版本
➜  git:(master) sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14
BuildVersion:	18A391
Error info:
  File "/usr/local/Cellar/python@2/2.7.15/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 "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/anydbm.py", line 84, in open
    mod = __import__(result)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dbhash.py", line 7, in <module>
    import bsddb
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bsddb/__init__.py", line 67, in <module>
    import _bsddb
ImportError: No module named _bsddb

修正方式:

将dbhash.py 这个文件里import bsddb 改为 import bsddb3 as bsddb,我virutalenv的dbhash文件位置在:

/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/dbhash.py
try:
    #import bsddb
    import bsddb3 as bsddb
except ImportError:
    # prevent a second import of this module from spuriously succeeding
    del sys.modules[__name__]
    raise

posted @ 2019-01-18 15:14  小小leo  阅读(490)  评论(0编辑  收藏  举报