- type:
- text //
- 2010.Jan.1
- 10.37pm
- // tagged:
- python
- django
- mac
- snow leopard
Snow Leopard’s Python 2.6 site-packages (and a psycopg2 issue)
THE ULTIMATE EDIT: I’ve got new instructions on how to conquer Symbol not found: \_PQbackendPID! Check them out here.
Maybe I’m a newb, maybe I’m not a newb. But I had a hard time installing Django (from scratch) on my new install of Mac OS X 10.6 Snow Leopard. It appears my issue was with the site-packages location. It’s got python26 installed by default, installed in
/System/Library/Frameworks/Python.framework
So I ran my handy site-packages finding command:
python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
It gave me this path.
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages
So I linked Django to that directory. But when I tested my setup to see if it would load the Django modules, it wouldn’t. So I printed my pythonpath (going into the python shell and running import sys; print sys.path) and I found the only default site-packages directory in pythonpath.
/Library/Python/2.6/site-packages
Once I linked Django there, it worked like a charm. Hope this saves you a 5-minute headache or something.
Update: I also ran into a bit of a tiff installing psycopg2 from source. I ran the following commands, which installed psycopg2 into the previously-listed System site-packages path:
python setup.py build
sudo python setup.py install
Rather, once I ran the easy install command (the setuptools for this seem to be included), my python setup found all the modules it needed for PostgreSQL integration.
easy_install .
Again, hope this helps another 5-minute headache!
Another edit: there’s been some discussion in the comments about a problem with PostgreSQL/Python integration throwing errors in Snow Leopard. Namely, it’s the following error message:
Symbol not found: _PQbackendPID
The general, scientific Internet consensus is that it’s due to a weird mixture of 32-bit plugins with a 64-bit process. Until more and more things become available as 64-bit, you’ll probably want to run Apple’s build of Python 2.6 as 32-bit for the time being. Here’s the terminal command to do just that.
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
Not sure if that needs to be run with sudo, but there you have it. Thanks to @Mark and @John Simons for laying this out and explaining it.

