Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install libpq-dev on Mac OS X

I'm trying to run Django with a Postgresql backend on my local Mac OS X. I've installed Django using pip:

sudo pip install Django

I've installed Postgresql with one of the binary installers here.

But when I try to install psycopg2 I get an error (pasted below) that it can't find pg_config.

From this question it seems like I should install libpq-dev but I'm not sure how.

I've tried installing libpqxx with MacPorts, but that hasn't done anything.

How do I get libpg-dev installed? Or is there something else I'm missing?

henrietta:~ $ pip install psycopg2
Downloading/unpacking psycopg2
  Downloading psycopg2-2.4.5.tar.gz (719Kb): 719Kb downloaded
  Running setup.py egg_info for package psycopg2
    Error: pg_config executable not found.

    Please add the directory containing pg_config to the PATH
    or specify the full executable path with the option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.
    Complete output from command python setup.py egg_info:
    running egg_info

creating pip-egg-info/psycopg2.egg-info

writing pip-egg-info/psycopg2.egg-info/PKG-INFO

writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt

writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt

writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

warning: manifest_maker: standard file '-c' not found

Error: pg_config executable not found.



Please add the directory containing pg_config to the PATH

or specify the full executable path with the option:



    python setup.py build_ext --pg-config /path/to/pg_config build ...



or with the pg_config option in 'setup.cfg'.

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/thomas/.pip/pip.log
like image 457
tchaymore Avatar asked Apr 12 '12 21:04

tchaymore


People also ask

What is Libpq-Dev?

libpq-dev 9.0. 0goal is to provide all requirements for building `Psycopg2`_. This package is meant to be built as `platform-specific`_ binary. `Python wheels`_, contains only PostgreSQL binaries and 0 Python code.

Where can I buy Libpq?

Libpq is included in the full PostgreSQL source code. You can use just libpq without the rest of PostgreSQL, but must download the full package. You can download it from the PostgreSQL Downloads page. Once you extract the full package it is inside src\interfaces\libpq .


2 Answers

For OSX 10.9.2 Mavericks, this is what worked for me. Try installing postgres with brew first:

brew install postgresql

Then install pg

gem install pg
like image 192
esilver Avatar answered Oct 29 '22 11:10

esilver


So I ended up following the advice here:

http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/

Turns out I did have pg-config installed, but I had to dig around to find it a bit. Once I included that in the path, everything worked swimmingly. Here's the snippet from that link:

PATH=$PATH:/Library/PostgresPlus/8.3/bin/ sudo easy_install psycopg2

I used pip instead of easy_install and my PostgreSQL installation directory was slightly different, but that's the gist.

like image 38
tchaymore Avatar answered Oct 29 '22 13:10

tchaymore