Trying to setup postgres with the postgres mac app and hit this error, which I haven\'t been able to solve. Any thoughts?
ImportError: dlopen(/Users/Crai
pip install psycopg2-binary
works like a charm!
Discussion on source+wheel distribution (pyscopg2) vs a separate binary distribution (psycopg2-binary): https://www.postgresql.org/message-id/CA%2Bmi_8bd6kJHLTGkuyHSnqcgDrJ1uHgQWvXCKQFD3tPQBUa2Bw%40mail.gmail.com
Explanation on the decision to release psycopg2-binary: http://initd.org/psycopg/articles/2018/02/08/psycopg-274-released/
However, there are reports of psycopg2-binary not satisfying psycopg2 dependencies. More discussion here: https://github.com/psycopg/psycopg2/issues/674
Just wanted to share what worked for me. I was using Anaconda with jupyter. The following did work:
DYLD_LIBRARY_PATH=/usr/local/Cellar/openssl/1.0.2k/lib jupyter notebook
But then caused later issues importing another library (plotly). After playing around with pip, I realised I should probably be using conda instead and the following seemed to fix everything.
conda install psycopg2
In case if you are working on python/django with virtual environment
Worked for me for the following Version
3 Steps Solutions
I had the same error because of upgrading Postgres.app (from 9.3 to 9.4).
The solution was to delete the pip cache wheels because they were pointing to Postgres.app version 9.3.
I've found the according psycopg wheel cache files this way
grep -r psycopg ~/.pip/cache
and deleted the directory I've found with the last command.
This problem cost me the whole morning to solve. I found the discussion on http://initd.org/psycopg/articles/2010/11/11/links-about-building-psycopg-mac-os-x/ really helpful. Thanks to Jurie's answer, the solution to my problem (in Mac) is as below:
Install openssl 1.0.0 using brew:
brew install openssl
using the following command:
export DYLD_LIBRARY_PATH=/usr/local/Cellar/openssl/**1.0.1x**/lib
replace 1.0.1x part with your current version. For me it is 1.0.1h.
Hope this helps!
EDIT: After one day, I found that the second command has to be entered every time when needing to connect to database, so not a permanent solution to this problem.
I encountered this issue when I upgraded from postgres.app 9.4 to 9.5 on el capitan.
The other solutions will not work (easily) in el capitan because of the system lock on certain directories, meaning the symbolic link solution will be less accessible/ideal for most.
This leaves the fallback variable. The current answer points to the wrong directory. I am guessing the dylibs directory has changed since 2013.
So, here is the latest fallback directory that works for me:
export DYLD_FALLBACK_LIBRARY_PATH=/Applications/Postgres.app/Contents/Versions/latest/lib:$DYLD_LIBRARY_PATH