5

I'm desperately trying to successfully install psycopg2 but keep running into errors. The latest one seems to involve it not being to find "stdarg.h" (see code below). However I can see with my own eyes that a file called stdarg.h exists at /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h (where it claims it can't find anything) so I've no idea what to do about it.

I'm running Mac OS 10.6.3 and within the last few days I've made sure I have all the latest OS developer tools.

I have Python 2.6.2 and PostgreSQL 8.4 if that makes any difference.

python setup.py install    
running install
running build
running build_py
running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.macosx-10.3-fat-2.6
creating build/temp.macosx-10.3-fat-2.6/psycopg
gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPG_VERSION_HEX=0x080404 -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -I/opt/local/include/postgresql84 -I/opt/local/include/postgresql84/server -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
             from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
             from psycopg/psycopgmodule.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
In file included from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/unicodeobject.h:4,
             from /Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:85,
             from psycopg/psycopgmodule.c:27:
/Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
lipo: can't figure out the architecture type of: /var/folders/MQ/MQ-tWOWWG+izzuZCrAJpzk+++TI/-Tmp-//ccakFhRS.out
error: command 'gcc' failed with exit status 
Nicolas Holzapfel
  • 235
  • 1
  • 2
  • 11

3 Answers3

3

I don't know your specific problem but i recommend you to install it using macports.
Installing psycopg2 is as simply as:

sudo port install py26-psycopg2
systempuntoout
  • 71,966
  • 47
  • 171
  • 241
  • 2
    @cojadate it depends on what version of Python you are currently using. If you are running with python2.6 , py26-psycopg2 is the right choice. psycopg2 is surely installed but i guess is not in your Python path. – systempuntoout Jun 15 '10 at 14:10
  • 1
    @cojadate If you installed psycopg2 using MacPorts, you need to make sure that you're using the ports version of Python instead of the one that ships with OSX. Make sure `/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/` or similar is in your `PATH` before `/usr/bin` or what-have-you. – Hank Gay Jun 18 '10 at 17:17
3

The following works for me:

  1. $ mkvirtualenv --no-site-packages --distribute psycopg2_test
  2. $ cd $VIRTUAL_ENV
  3. $ pip install psycopg2

Notes

  • I installed my base Python via MacPorts.
  • The above commands make use of:

  • I bootstrapped pip via the following:

    1. wget http://python-distribute.org/distribute_setup.py
    2. python distribute_setup.py
    3. easy_install pip

UPDATE: I realize it seems like a lot of yak shaving, but learning how to use virtualenv and friends is an up-front investment that pays off pretty quickly, especially when dealing with projects that have a lot of dependencies.

Hank Gay
  • 70,339
  • 36
  • 160
  • 222
1

I actually had a very similar problem as this (except with OSX Lion, Python 2.7) Can't install psycopg2 in virtualenv "error: stdarg.h: No such file or directory".

I ended up using this solution: https://stackoverflow.com/a/8834568/396327

Basically, uninstalling/reinstalling XCode from scratch (and a few more hacks to get it to recognize gcc-4.2).

Community
  • 1
  • 1
fangsterr
  • 3,670
  • 4
  • 37
  • 54