Os X 10.8.2 Python 3 Import Sqlite Error
Solution 1:
The module is named sqlite3
, not sqlite
:
import sqlite3
http://docs.python.org/3/library/sqlite3.html
Update: Now that we've cleared up the module name, the problem being reported:
ImportError: No module named '_sqlite3'
means that your Python instance cannot find the C extension module, _sqlite3.so
, that is part of the sqlite3
module in the standard library. Since the file path of the dbapi2.py
in the traceback looks reasonable, the issue is probably not a path issue (sys.path
). Most likely the _sqlite3
extension module failed to build or link. Check the output from your Python build for errors. OS X 10.8 includes a version of sqlite3
but for security reasons it does not include the optional loadable extensions feature. Your Python build likely included this message:
Failed to build these modules:
_sqlite3
and, earlier, this:
*** WARNING: renaming "_sqlite3" since importing it failed: dlopen(build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so, 2): Symbol not found: _sqlite3_enable_load_extension
Referenced from: build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
Expected in: flat namespace
in build/lib.macosx-10.8-x86_64-3.3-pydebug/_sqlite3.so
The solution is to build and install a separate copy of sqlite3 that is built with the loadable extensions feature. If you are using Homebrew, its sqlite
recipe with the with-functions
option should do that. Then rebuild Python.
Solution 2:
Homebrew provides python3 with sqlite3 support and loadable modules.
brew install python3
will do the right thing (and brew sqlite, too).
There was a bug, that probably struck you, but it has been fixed
Post a Comment for "Os X 10.8.2 Python 3 Import Sqlite Error"