2
I’m getting beat up with Python + Postgre and Psycopg2.
I installed Python 3.4 on my MAC, then Postgre and then followed the following steps:
export PATH=/Library/PostgreSQL/9.4/bin:$PATH
pip install psycopg2
He installed Psycopg 2, but when I give an import I get the following error:
/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4 /Users/leandro/PycharmProjects/Teste/teste.py
Traceback (most recent call last):
File "/Users/leandro/PycharmProjects/Teste/teste.py", line 1, in <module>
import psycopg2
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: libssl.1.0.0.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/psycopg2/_psycopg.so
Reason: image not found
Process finished with exit code 1
On the web I found references to do the following:
sudo mv /usr/lib/libpq.5.dylib /usr/lib/libpq.5.dylib.old
sudo ln -s /Applications/Postgres.app/Contents/Versions/9.4/lib/libpq.5.dylib /usr/lib
or
sudo ln -s /Library/PostgreSQL/9.4/lib/libpq.5.dylib /usr/lib
But it didn’t solve ... Some hint?
My tip would be to install all this in an isolated and not direct environment on Mac OS, look for virtualenv.
– Paulo
I also recommend using virtualenv, create a venv with python3 and try running Pip with active venv, most likely solve your problem.
– drgarcia1986
In virtualenv he complains that he does not find pg_config although he has already set the path in path.
– Leandro Garcia