title: Installing psycopg2 into virtualenv when PostgreSQL is not installed on development system
body: <p>Is it possible to install <a href="http://initd.org/psycopg/" rel="noreferrer"><code>psycopg2</code></a> into a <code>virtualenv</code> when PostgreSQL isn't installed on my development system—MacBook Pro with OS X 10.6?</p>
  
  <p>When I run <code>pip install psycopg2</code> from within my <code>virtualenv</code>, I received the error shown below.</p>
  
  <p>I'm trying to connect to a legacy database on a server using Django, and I'd prefer not to install PostgreSQL on my development system if possible.</p>
  
  <h2>Why not install PostgreSQL?</h2>
  
  <p>I received an error when installing PostgreSQL using homebrew. I have Xcode4—and only Xcode4—installed on my MacBook Pro and am thinking it's related to missing gcc 4.0. However, this is a problem for another StackOverflow question.</p>
  
  <p><strong>Update 8:37 AM on April 12, 2011:</strong> I'd still like to know if this is possible without installing PostgreSQL on my MacBook Pro. However, I ran <code>brew update</code> and forced a reinstallation of ossp-uuid with <code>brew install --force ossp-uuid</code> and now <code>brew install postgresql</code> works. With PostgreSQL successfully installed, I was able to <code>pip install psycopg2</code> from within my virtualenv.</p>
  
  <h2>Error from <code>pip install psycopg2</code></h2>
  
  <pre><code>$ pip install psycopg2
  Downloading/unpacking psycopg2
    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
  
  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
  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/matthew/.pip/pip.log
  </code></pre>
  
  <h2>Preliminary Research</h2>
  
  <p>Below are the articles I read as preliminary research:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/q/4430860/95592">Installing psycopg2 to use Django with PostgreSQL on OS X</a></li>
  <li><a href="http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/" rel="noreferrer">Installing psycopg2 on OS X</a></li>
  <li><a href="http://www.saltycrane.com/blog/2009/07/using-psycopg2-virtualenv-ubuntu-jaunty/" rel="noreferrer">Using psycopg2 with virtualenv on Ubuntu JauntyLucid</a></li>
  <li><a href="http://koansys.com/tech/postgres-psycopg2-virtualenv-install-hints" rel="noreferrer">Postgres, psycopg2, virtualenv install hints</a></li>
  </ul>