7

I want to use sqlite with the json extension so I've installed it with homebrew. When I run which sqlite though, the one that is being used is the anaconda install. If I try and use pythons sqlite library I have the same issue. It's linked to the Anaconda version and the JSON functions aren't available. How do I replace this with the brew version? Brew provided some values when I installed sqlite but I don't know if I need them or how they are used.

LDFLAGS: -L/usr/local/opt/sqlite/lib CPPFLAGS: -I/usr/local/opt/sqlite/include PKG_CONFIG_PATH: /usr/local/opt/sqlite/lib/pkgconfig

2 Answers 2

10

Sqlite installed by Homebrew is keg-only, which is not linked to /usr/local/... .
This is because system already have older version of sqlite3.

If you really want to invoke Homebrew's sqlite binary, specify full path as below.

$ /usr/local/opt/sqlite/bin/sqlite3

(All Homebrew package is symlinked under /usr/local/opt)

I'm not so familiar with python, but AFAIK sqlite is statically linked to python executable.
In other words, maybe you have to build python from source to use with Homebrew's sqlite.

3
  • 1
    Running sqlite3 still invokes the system sqlite. If I run sqlite i get command not found.
    – Marcus
    Commented Dec 30, 2016 at 8:50
  • That works for accessing it on the command line but the python library is still linked to the system version :(
    – Marcus
    Commented Dec 30, 2016 at 10:09
  • 1
    This makes it simpler for the command line. echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.bash_profile Commented Nov 28, 2017 at 6:47
2

The answer by equal-l2 is correct. Also, the comment under it by Keith John Hutchison.

But, since they are from quite a few years ago and there is not an officially accepted answer still, here you go as this still catches you off-guard in 2022.

To fix, add this to your ~/.zshrc file and you should be good:

export PATH=/usr/local/opt/sqlite/bin:$PATH

Remember to have $PATH at the end like the above and not at the beginning like so:

export PATH=$PATH:/usr/local/opt/sqlite/bin

as the shell traverses your $PATH for command completion left to right and stops at the first instance found and obviously you want your desired path to be considered first.

Also, you might need to run source ~/.zshrc and rehash if you want it to just start working in the same terminal session.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.