I’d decided a while ago to invest some time learning Python, already had MAMP Pro happily running on my MacBook Pro running OS X 10.4 so it made sense to push further and have a look at Django – the Python Web Framework. I’m following the beautifully written Django Book and an amalgam of google results.
My Python was previously obtained from pythonmac.org as the shipped version wasn’t current enough to easily follow a few Blender based tutorials I was interested in.
I know it’s running and confirm the version by typing the following into a Terminal window:
matt$ python -V
Python 2.4.4
Next I added MySQL support to python by downloading the precompiled MySQLdb package from pythonmac.org. Unzipping provides an installer so you just click your way through the dialogues and confirm that the magic is done by starting up python in your terminal window and importing the MySQLdb module.
matt$ python
Python 2.4.4 (#1, Oct 18 2006, 10:34:39)
[GCC 4.0.1 (Apple Computer, Inc. build 5341)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
No errors means you’re good.
Now, as we’re going to be using the Apache shipped with MAMP to serve our Django apps we need to install mod_python. Stuart Colville’s experiences compiling mod_python for mamp didn’t fill me with confidence but I’d thought I’d go ahead and give it a stab so I downloaded from the Apache Server Project unpacked it and followed the suggestion that a simple ./configure would do. Here’s what I got:
matt$ ./configure --with-apxs=/Applications/MAMP/Library/bin/apxs --with-python=/usr/local/bin/python
checking for gcc... no
checking for cc... no
checking for cc... no
checking for cl... no
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details.
Ouch! The book says that installing Django is easy and I haven’t even got to the end of the first real page. But wait! I don’t actually need the Apache part of MAMP just yet as explained
Django includes a built-in, lightweight Web server you can use while developing your site. We’ve included this server so you can develop your site rapidly, without having to deal with configuring your production Web server (e.g., Apache) until you’re ready for production.
So, ignoring the distraction of fiddling with Apache (for now), the “Congratulations on your first Django-powered page.” is soon presented with the sassy addition of
Of course, you haven’t actually done any work yet. Here’s what to do next:
- If you plan to use a database, edit the DATABASE_* settings in mysite/settings.py.
- Start your first app by running python mysite/manage.py startapp [appname].
It worked!
Powered by Wordpress
Using the 960 Grid System CSS layout framework


3 responses so far ↓
1 Stuart Colville // Apr 3, 2008 at 3:36 pm
To have a compiler on your mac you’ll need xcode which you can install from the install disc or download from http://developer.apple.com/tools/xcode/
Also bear in mind that my instructions for installing mod_python are probably fairly out of date now – be sure to read the comments afaik mamp are now shipping a version with all of the source files which makes life a lot easier.
Also note that personally I’d now recommend using mod_wsgi over mod_python. You can find out about this from http://modwsgi.org/
2 Matt Bracewell // Apr 4, 2008 at 12:05 am
I’ve just had a quick look at mod_wsgi and I suspect that I’ll go this way when I make it to Chapter 20 – only 18 more to go!
Looks like I’ll need to get compiling for that so thanks for the xcode tip.
3 Django on MAMP Part2 compiling mod_wsgi — blog.bracewell.org // Apr 20, 2008 at 7:56 pm
[...] a follow on from Django on OS X – getting started here’s what happened after I took Stuart’s advice, installed Xcode and atempted to add [...]
Leave a Comment