Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python import sqlite error

Tags:

python

sqlite

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?

like image 490
Desmond Chen Avatar asked Mar 24 '13 05:03

Desmond Chen


1 Answers

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
like image 115
Erik Kaplun Avatar answered Sep 24 '22 11:09

Erik Kaplun