How do I run psycopg2 on El Capitan without hitting a libssl error
I tried the following:
I have brew installed on my machine. Running $ brew doctor
gave me a suggestion to do the following:
$ sudo chown -R $(whoami):admin /usr/local
Once this was done, I re-installed psycopg2
and performed the following:
$ sudo ln -s /Library/PostgreSQL/9.3/lib/libssl.1.0.0.dylib /usr/local/lib/$ sudo ln -s /Library/PostgreSQL/9.3/lib/libcrypto.1.0.0.dylib /usr/local/lib/
Please note the version of your PostgreSQL and the path /usr/local/lib
.
Doing this got me back to a working setup again.
P.S.: The brew suggested step might not be relevant here but I put this up because you were seeing permission issues. You could also disable rootless mode.
The reason is indeed psycopg2 using relative paths to a few PostgreSQL libraries. To fix it I used
sudo install_name_tool -change libpq.5.dylib /Library/PostgreSQL/9.4/lib/libpq.5.dylib /Library/Python/2.7/site-packages/psycopg2/_psycopg.sosudo install_name_tool -change libcrypto.1.0.0.dylib /Library/PostgreSQL/9.4/lib/libcrypto.1.0.0.dylib /Library/Python/2.7/site-packages/psycopg2/_psycopg.sosudo install_name_tool -change libssl.1.0.0.dylib /Library/PostgreSQL/9.4/lib/libssl.1.0.0.dylib /Library/Python/2.7/site-packages/psycopg2/_psycopg.so
to convert the relative paths to absolute ones. Of course you'd need to do this every time you reinstall psycopg2.
Do you use anaconda? If so a very simple solution that worked for me was to simply install using conda.
Specifically, enter the following in at the command line:
conda install psycopg2