I did a simple pip install psycopg2
on mac system. It installed fine, but when I try to use psycopg2 I get the error:
Reason: Incompatible libra
On OSX 10.11, El Capitan, solution with replacing symlinks reported Operation not permitted
. Solution that worked for me was using brew and setting up DYLD_LIBRARY_PATH. So:
brew install openssl
Find where openssl brew libs are located (brew --prefix openssl
can help), start searching from directory /usr/local/Cellar/openssl
. In my case it is in /usr/local/Cellar/openssl/1.0.2d_1/lib
Finally set up DYLD_LIBRARY_PATH, i.e. add a line like this into .bash_profile :
# replace location of lib files with folder name you found in previous step
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/Cellar/openssl/1.0.2d_1/lib
UPDATE: More generic/better alternatives are (thanks to @dfrankow):
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$(brew --prefix openssl)/lib
DYLD_FALLBACK_LIBRARY_PATH
instead - check thisRestart shell, or just source ~/.bash_profile
, reinstall psycopg2:
pip uninstall psycopg2
pip install psycopg2
and test if it works:
$ python -c"import psycopg2 ; print('psycopg2 is now ok')"