I can't install psycopg2 on my m1 Mac. I tried to reinstall openssl with brew. I tried a lot of thing but nothing changed. The error log is super long so I couldn't understand what is wrong. I am facing up with this error when I try to pip install psycopg2
Waiting for your help.
Here is the full error log: https://wtools.io/paste-code/b4jG
Asked
Active
Viewed 1,391 times
6

Rheawin
- 94
- 8
-
Try running `xcode-select --install` first. – Ben Mar 16 '21 at 17:47
-
Yeah I already did that – Rheawin Mar 16 '21 at 17:50
-
Does `pip install psycopg2-binary` work ? – Maurice Meyer Mar 16 '21 at 18:22
-
nope same error occurs – Rheawin Mar 16 '21 at 19:22
-
I am still waiting for responses... – Rheawin Mar 17 '21 at 12:01
1 Answers
10
The error is happening because it seems to be having some problem with ssl. I used different answers from a similar question to solve it for myself:
Install openssl if you don't have:
brew install openssl
Check the path where openssl got installed using:
brew --prefix openssl
Use output from above and add LD flag when running the pip command, for example in my case the output was
/opt/homebrew/opt/openssl@1.1
so I did the following:LDFLAGS="-I/opt/homebrew/opt/openssl@1.1/include -L/opt/homebrew/opt/openssl@1.1/lib" pip install psycopg2
And that did the trick for me.

Saravanan Setty
- 408
- 5
- 20
-
1Thanks a million... It works and you saved my couple of days. Thank you very much. You are the best. – Rheawin Mar 18 '21 at 17:13
-