title: how to install psycopg2 on OSX 10.7
body: <p>I followed the following procedure:</p>
  
  <p>1) <code>$ sudo pip install psycopg2</code></p>
  
  <p>This gave me the following error</p>
  
  <pre><code>Downloading/unpacking psycopg2
    Running setup.py egg_info for package psycopg2
  
      no previously-included directories found matching 'doc/src/_build'
  Installing collected packages: psycopg2
    Running setup.py install for psycopg2
      building 'psycopg2._psycopg' extension
      llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.3 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090004 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.7-intel-2.7/psycopg/psycopgmodule.o
      unable to execute llvm-gcc-4.2: No such file or directory
      error: command 'llvm-gcc-4.2' failed with exit status 1
      Complete output from command /usr/bin/python -c "import setuptools;__file__='/Users/boltellinfomedia/mukul/mukul/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-8NaS72-record/install-record.txt:
      running install
  
  running build
  
  running build_py
  
  running build_ext
  
  building 'psycopg2._psycopg' extension
  
  llvm-gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.4.3 (dt dec pq3 ext)" -DPG_VERSION_HEX=0x090004 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I. -I/usr/include -I/usr/include/postgresql/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.7-intel-2.7/psycopg/psycopgmodule.o
  
  unable to execute llvm-gcc-4.2: No such file or directory
  
  error: command 'llvm-gcc-4.2' failed with exit status 1
  
  ----------------------------------------
  Command /usr/bin/python -c "import setuptools;__file__='/Users/boltellinfomedia/mukul/mukul/build/psycopg2/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-8NaS72-record/install-record.txt failed with error code 1
  Storing complete log in /Users/boltellinfomedia/.pip/pip.log
  </code></pre>
  
  <p>2) Then I searched on web for installing llvm-gcc-4.2 and from this <a href="http://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-llvm-gcc/_index.html" rel="nofollow noreferrer">http://developer.apple.com/library/mac/#releasenotes/DeveloperTools/RN-llvm-gcc/_index.html</a>
  got to know that I need to install Xcode</p>
  
  <p>Also from this <a href="https://stackoverflow.com/questions/6805433/psycopg2-installation-problem-on-osx-lion">psycopg2 installation problem on OSX Lion</a> I came to know that I can install psycopg2 via macports but then from this <a href="http://www.macports.org/install.php" rel="nofollow noreferrer">http://www.macports.org/install.php</a> came to know that I need xcode again.</p>
  
  <p>3) Finally I tried to install Xcode from apple store, it downloaded 1.6 gb file and after that says that it is now installed on my system. Here is the screenshot of the same</p>
  
  <p>![macports installed image][1] </p>
  
  <p>4) And then I tried to install macports via the dmg file available at <a href="http://www.macports.org/install.php" rel="nofollow noreferrer">http://www.macports.org/install.php</a> but it says that xcode not yet installed on my system. Here is the screenshot of the same. ![when trying to install macport, xcode not installed message appears][2]</p>