7

python2.7 和 sqlite3 由 homebrew 在 macos 10.8
上安装 pysqlite 由 pip 安装

当我在 python interapter 中键入 import sqlite3 时,它显示以下错误:

>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
from dbapi2 import *
  File "/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: dlopen(/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so, 2): Library not loaded: /usr/local/lib/libsqlite3.0.8.6.dylib
  Referenced from: /usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/_sqlite3.so
  Reason: image not found

如何纠正该错误?

4

1 回答 1

7

解决方案是同时卸载 thesqlitepythonkegs:

brew rm sqlite python

然后重新安装 Python(它也安装 SQLite3 作为它的依赖项):

brew install python
于 2013-10-04T20:05:06.710 回答