Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install psycopg2 package through pip install on MacOS

I am working on a project for one of my lectures and I need to download the package psycopg2 in order to work with the postgresql database in use. Unfortunately, when I try to pip install psycopg2 the following error pops up:

ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/clang' failed with exit status 1 ld: library not found for -lssl clang: error: linker command failed with exit code 1 (use -v to see invocation) error: command '/usr/bin/clang' failed with exit status 1 

Does anyone know why this is happening? Thanks in advance!

like image 319
Jome Avatar asked Sep 29 '16 10:09

Jome


People also ask

Does psycopg2 work with Python 3?

The current psycopg2 implementation supports: Python 2 versions from 2.6 to 2.7. Python 3 versions from 3.2 to 3.6. PostgreSQL server versions from 7.4 to 9.6.

Is psycopg2 the same as psycopg2-binary?

psycopg2-binary and psycopg2 both give us the same code that we interact with. The difference between the two is in how that code is installed in our computer.

Could not find a version that satisfies the requirement psycopg2?

Queries related to “could not find a version that satisfies the requirement psycopg2” You may install a binary package by installing 'psycopg2-binary' from PyPI. If you want to install psycopg2 from source, please install the packages required for the build and try again. PyPI 'psycopg2-binary' package instead.


1 Answers

I fixed this by installing Command Line Tools

xcode-select --install 

then installing openssl via Homebrew and manually linking my homebrew-installed openssl to pip:

env LDFLAGS="-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib" pip install psycopg2 

on macOS Sierra 10.12.1

like image 117
zganger Avatar answered Oct 23 '22 10:10

zganger