"Failed building wheel for psycopg2" - MacOSX using virtualenv and pip

Solution 1:

I had the same problem on Arch linux. I think that it's not an OS dependant problem. Anyway, I fixed this by finding the outdated packages and updating then.

pip uninstall psycopg2
pip list --outdated
pip install --upgrade wheel
pip install --upgrade setuptools
pip install psycopg2

hope this helps...

Solution 2:

For MacOS users

After trying all the above methods (which did not work for me on MacOS 10.14), that one worked :

  • Install openssl with brew install openssl if you don't have it already.
  • add openssl path to LIBRARY_PATH :
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
  • install psycopg2 with pip pip3 install psycopg2

Solution 3:

I was also getting same error. Using Python 3.7.3 and pip 19.1.1.

error screen

I used following command.

pip install psycopg2-binary==2.8.3