Search code examples
pythonanacondapsycopg2osx-elcapitan

Unable to install psycopg2 on OSX Anaconda


This is what I am getting:

Adnans-MBP:~ AdnanAhmad$ easy_install psycopg2
Searching for psycopg2
Reading https://pypi.python.org/simple/psycopg2/
Downloading https://pypi.python.org/packages/7b/a8/dc2d50a6f37c157459cd18bab381c8e6134b9381b50fbe969997b2ae7dbc/psycopg2-2.6.2.tar.gz#md5=4a392949ba31a378a18ed3e775a4693f
Best match: psycopg2 2.6.2
Processing psycopg2-2.6.2.tar.gz
Writing /var/folders/d3/t5c58nx570ggzzknhm4zpjnw0000gn/T/easy_install-66rCLK/psycopg2-2.6.2/setup.cfg
Running psycopg2-2.6.2/setup.py -q bdist_egg --dist-dir /var/folders/d3/t5c58nx570ggzzknhm4zpjnw0000gn/T/easy_install-66rCLK/psycopg2-2.6.2/egg-dist-tmp-Vu8qsu
In file included from psycopg/psycopgmodule.c:27:
./psycopg/psycopg.h:31:10: fatal error: 'libpq-fe.h' file not found
#include <libpq-fe.h>
         ^
1 error generated.
error: Setup script exited with error: command 'gcc' failed with exit status 1

I am using PostgreSql.app


Solution

  • well, since you are using anaconda anyways, might as well take advantage of their binary packages! They have one for PostgreSQL! just type

    conda install psycopg2