7

python2.7 and sqlite3 were installed by homebrew on macos 10.8
pysqlite is installed by pip

when I type import sqlite3 in python interapter, it show errors below:

>>> 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

how to correct that error?

4
  • 4
    github.com/mxcl/homebrew/issues/17312 Commented Mar 24, 2013 at 6:08
  • On my Mac Python 2.7, pysqlite and Sqlite 3 are installed by default. Couldn't you use those? Commented Mar 24, 2013 at 7:28
  • Why do you install a new version of Python when there are already Pyhon 2.7 installed by default ? It is a problem of Homebrew Commented Mar 24, 2013 at 9:16
  • 3
    @gene: because the Python that comes with OS X is usually a few minor versions behind the latest one. Commented Oct 4, 2013 at 20:06

1 Answer 1

7

The solution is to uninstall both the sqlite as well as python kegs:

brew rm sqlite python

and then reinstall Python (which also installs SQLite3 as its dependency):

brew install python
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.