Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symbol not found: _sqlite3_enable_load_extension - sqlite installed via homebrew

Symptom: In my Django app, when I call from pysqlite2._sqlite import * I get the traceback Symbol not found: _sqlite3_enable_load_extension when

Background:

  • I've installed python using homebrew (python 2.7.13), which auto installed sqlite
  • I am running macOS 10.12.3 with Command Line Tools macOS 10.12, Xcode 8.2.1
  • I've installed pysqlite using pip (pysqlite 2.8.3)

I have tried

  • brew uninstall sqlite and brew uninstall python and reinstalling
  • Adding these to my .bash_profile

    export PATH="$(brew --prefix sqlite)/bin:$PATH"
    LDFLAGS="-L/usr/local/opt/sqlite/lib"
    CPPFLAGS="-I/usr/local/opt/sqlite/include"
    export PKG_CONFIG_PATH=“/usr/local/opt/sqlite/lib/pkgconfig”
    
  • python -c "import sqlite3" doesn't return any errors

Gist of traceback: https://gist.github.com/xwchen/e9704fa34f0463d2117fe9fbb37922a1

like image 203
Xiao Wei Chen Avatar asked Feb 02 '17 04:02

Xiao Wei Chen


1 Answers

Copied answer from here (https://github.com/Homebrew/homebrew-core/pull/3134). If you're like me, you probably installed sqlite after you install python3. Anyway, if anyone stumbles upon this question and needs an answer...

First remove SQLite, python and python3 if installed via homebrew

brew uninstall --force python
brew uninstall --force python3
brew uninstall --force sqlite

This removes all copies.

Then make sure Xcode 8 or later is installed

Important

Re-install command line tools via

xcode-select --install
sudo xcode-select --reset

and finally install command line tools via pkg file found here.

Look for command line tools in search. (I've downloaded "Command Line Tools (macOS 10.12) for Xcode 8.dmg") Then open DMG and install the pkg found there.

Now install SQLite and then python and python 3 if needed:

brew install sqlite
brew install python
brew install python3

Run brew install python --verbose and make sure there are no warnings, if none then issues should be resolved.

Don't forget to do

pip install setuptools --upgrade && pip3 install setuptools --upgrade
like image 186
jaxon737 Avatar answered Sep 22 '22 06:09

jaxon737