Cannot install psycopg2 with pip3 on M1 Mac

We Are Going To Discuss About Cannot install psycopg2 with pip3 on M1 Mac. So lets Start this Python Article.

Cannot install psycopg2 with pip3 on M1 Mac

  1. How to solve Cannot install psycopg2 with pip3 on M1 Mac

    try this:
    brew install libpq --build-from-source brew install openssl export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib" export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include" pip3 install psycopg2

  2. Cannot install psycopg2 with pip3 on M1 Mac

    try this:
    brew install libpq --build-from-source brew install openssl export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib" export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include" pip3 install psycopg2

Solution 1

try this:

brew install libpq --build-from-source
brew install openssl

export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib -L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include -I/opt/homebrew/opt/libpq/include"

pip3 install psycopg2

Original Author user2884165 Of This Content

Solution 2

Before reverting to any of the older answers, I would recommend trying the following:

Install Postgres using brew install postgres, then pip3 install psycopg2.

Worked on Mac M1, Monterey, Python 3.9.

Thanks to Kori Vernon.

Original Author user3661992 Of This Content

Solution 3

Thanks to active development, now there is a new release of psycopg2 as well as psycopg2-binary which is compatible with M1 devices.
Ver. 2.9.1 works smooth. Tried and tested
Reference – https://github.com/psycopg/psycopg2/issues/1200

Original Author Shubhank Saxena Of This Content

Solution 4

Here’s a list of instructions of how to install postgressql and then add the pg_config to your path
https://stories.thirdbrain.ch/postgresql-psycopg2-macosx-python-error
That appears to be the error here

$ brew install postgresql
$ pg_ctl -D /usr/local/var/postgres start
$ brew install openssl

If you have already installed it, re-install

$ brew reinstall openssl

4 – Find the path of pg_config

$ find / -name pg_config  2>/dev/nul

5 – Check something like my path :

$ export PATH=$PATH:/usr/local/Cellar/postgresql/11.5_1/bin/pg_config

6 – Do the same thing with the lib ssl :

$ export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib

Original Author Brandon Kauffman Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment