Python, Django, PostgreSQL installation
8 September 2009 - Categories: Off Topic!
I spent (wasted) a full week back in April on connecting the right versions of Django, Python, and Postgres together on my Mac (running OS 10.5.7). Now it is September and on a whim, as if I had nothing better to do with my time, I decided to upgrade Python from 2.5 to 2.6, somehow forgetting what a mess this caused last time. Everything broke! Here’s how I put it back together, losing just 1 day this time. Hopefully next time I’ll just read this blog post and either stop in my tracks or use these commands.
First install MacPorts. Back in April this is the path that worked for me for getting Postgresql 8.3 and Python 2.5 talking to each other. It installs software, including dependancies, and then figures out how to get everything to hook together.
Today, to upgrade python from 2.5 to 2.6, you type this MacPorts command:
> sudo port install python26
Then you have to tell your machine that 2.6 is the version you want it to use:
> sudo python_select python26
Then you have to reinstall your current installation of django so that it is attached to 2.6, not 2.5
> cd to-your-Django-install
> python setup.py install
Now you have to reinstall that darned psycopg2 connection between Postgres and Python
> sudo port install py26-psycopg2
That last step can take forever, but be patient, because after this step, you can go back to your Django project and type:
> python manage.py runserver
And it will run your application! YAHOO.
A final last step: configure your Eclipse environment is to tell it to use 2.6 for compilation. Within the Pydev perspective, right-click on your project, click PyDev – project type, and under Interpreter click on “Click here to configure an interpreter not listed.” Then add a new Python Interpreter, which took some poking around, but finally “/opt/local/Library/Frameworks/Python.framwork/Versions/2.6/bin/python2.6″ worked (but isn’t what is finally displayed in the window).
Helpful resources:
- Stack Overflow is a pretty useful site and this post helped: http://stackoverflow.com/questions/1213690/what-is-the-most-compatible-way-to-install-python-modules-on-a-mac
- MacPorts download site: http://www.macports.org/
- Some terminal commands I found useful
> sudo port installed (tells you what you have installed)
> locate psycopyg (tells you where you have this driver installed — about 1,000,000 places in my case)

The


I can’t hide my opinion from the blogosphere any more. To all Americans: please, please pay attention to the important issues facing this country. And then please VOTE. Think about the problems we have in the US and the World and think about what you want done about them. And then please VOTE. 





