I ran pip install psycopg2-binary and it worked like charm
More info about the binary package
Python 3
pip3 install psycopg2-binary
Answer from Laban on Stack Overflowpsycopg2 install on macOS
psycopg2-binary fails to install on macOS Big Sur 11.0.1 and Python 3.9.0 (with possible workaround)
psycopg2 not being installed!! (same with psycopg2-binary)
pip2 install psycopg2 raise error on MacBook Air (M1, 2020)
Videos
I ran pip install psycopg2-binary and it worked like charm
More info about the binary package
Python 3
pip3 install psycopg2-binary
You don't seem to have postgres installed, check how to install postgresql in your system, one of the way is
brew install postgresql (if you use homebrew- recommended)
or download the postgres app from postgresapp.com, pg_config should come with postgres and psycopg2 is trying to find it.
So I'm not a "mac guy", but I have a system running High Sierra that I need to install psycopg2 on. I did the following:
Installed Python 3.9.6 from python.org installer
Installed PostgreSQL 13 from official installers
Added PostgreSQL binaries directory to my PATH
Ran
pip3 install --user psycopg2-binary
It all seems to go through, but I get an error trying to import psycopg2 in my Python3 environment:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/myuser/env/lib/python3.9/site-packages/psycopg2/__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Users/myuser/env/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Users/myuser/env/lib/python3.9/site-packages/psycopg2/.dylibs/libcrypto.1.1.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /Users/myuser/env/lib/python3.9/site-packages/psycopg2/.dylibs/libcrypto.1.1.dylibI have seen people talk about installing Python or PostgreSQL via homebrew, but for various reasons that's not an option in this situation. How can I get this working using official installers?
» pip install psycopg2
» pip install psycopg2-binary