Sep 17, 2008 Comments Off
Announcing Pedantic Bastard
Pedantic Bastard is a blog about being pedantic written by my alter ego. Please don’t read it.
Sep 17, 2008 Comments Off
Pedantic Bastard is a blog about being pedantic written by my alter ego. Please don’t read it.
Sep 12, 2008 Comments Off
The Apache httpd that comes with Mac OS X Leopard runs in 64-bit mode, so everything else that’s loaded, including mod_wsgi and psycopg2 must be able to run in 64-bit mode as well. Graham Dumpleton explained this behaviour in a post to the django-users mailing list.
Compiling psycopg2 using MacPorts as well as from the tarball would result in something like this when loaded from a web application that runs on Apache:
ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Library/Python/2.5/site-packages/psycopg2/_psycopg.so, 2): no suitable image found. Did find: /Library/Python/2.5/site-packages/psycopg2/_psycopg.so: no matching architecture in universal wrapper
So all I needed to do was force psycopg2 extension to be built for 64-bit as well as 32-bit. After extracting the latest psycopg2 source, do this instead:
LDFLAGS="-arch ppc -arch i386 -arch x86_64" CFLAGS="-arch ppc -arch i386 -arch x86_64" python setup.py build
Then sudo python setup.py install. After that, check the .so file, it should look something like this:
$ file /Library/Python/2.5/site-packages/psycopg2/_psycopg.so
/Library/Python/2.5/site-packages/psycopg2/_psycopg.so: Mach-O universal binary with 3 architectures
/Library/Python/2.5/site-packages/psycopg2/_psycopg.so (for architecture i386): Mach-O bundle i386
/Library/Python/2.5/site-packages/psycopg2/_psycopg.so (for architecture ppc7400): Mach-O bundle ppc
/Library/Python/2.5/site-packages/psycopg2/_psycopg.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
Don’t forget to restart Apache, and that should be it.
Update: It happened to PIL too, it was giving this error: The _imaging C module is not installed, so I had to do the same thing as above: LDFLAGS=... CFLAGS=... python setup.py build followed by sudo python setup.py install.