I have been stuck on this issue for some time. After struggling to install psycpg2 on my Mac I got a friend to help me install it using this:
env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip3 install psycopg2
I then imported psycopg2
I tried to run my db program and got this error:
Traceback (most recent call last):
File "postgresdemo.py", line 1, in <module>
import psycopg2
File "/Users/nkosana/Library/Python/3.7/lib/python/site-packages/psycopg2/__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Users/nkosana/Library/Python/3.7/lib/python/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so, 2): Symbol not found: _PQencryptPasswordConn
Referenced from: /Users/nkosana/Library/Python/3.7/lib/python/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so
Expected in: /usr/lib/libpq.5.dylib in /Users/nkosana/Library/Python/3.7/lib/python/site-packages/psycopg2/_psycopg.cpython-37m-darwin.so
System and versions
MacOS Catalina (10.15.4)
psycopg2-2.8.5
Python 3.7.3
I would appreciate your help, thanks in advance.