Mac Django MySQLdb Problems and Bitnami Love
I have an idea for a web property and wanted to explore Django as a way to create a prototype. I grabbed the two basic Django books and they each take you through the "how to install Django" bit. They start the discussion about setting up MySQL (assuming of course that you remember how that works), and then they each get to an innocent line that effectively says: You'll need the Python MySQL package (MySQLdb).
Now the fun begins. There's sometimes a wee bit of a problem building it on a Mac due to a confusion between 32-bit and 64-bit and PPC and Intel and which MySQL and which Python you might be using or have installed. I learned this much by poking about for awhile on Google. It took me a bit to realize I hadn't updated my developer Xtools world when I upgraded to Mac OS Leopard so that I was at least seeing the errors that others have reported. [The best summary is here if you want to do this the hard way.] A friend cautioned me around messing with the stock MySQL and Python worlds on the Mac, as it's a good way to make the shipped tools unusable if you don't get the builds right. I'm now a couple or three hours into the problem.
Then I have a brilliant idea. I'm an adviser to Bitrock, and on Bitnami they support a large collection of open source technology packages for Windows, Linux, Mac OSX (and Solaris). The packages are single-click installers that deliver the open source technology and all of its dependencies. The technology is installed in separate trees such that they do not interfere with the stock installed Mac packages. (There are easy ways to combine the packaged technologies if you don't want multiple instantiations of MySQL, Apache, etc.)
Sure enough, there's a Django stack for Mac OSX. A few minutes of download, a few minutes of install (and the autoconfiguration prompts for MySQL user setup before the install), and it's time for the big test. But wait: there's even an executable file in the install root called use_djangostack that seems to set my environment correctly. NOW it's time for the big test:
That was a lot less painful than any of the alternatives. Now I can get back to exploring Django. If you want to explore open source software technology in a sand box or easily set up an application like WordPress, Joomla, Drupal, or MediaWiki, I would encourage you to take a look at Bitnami. There's lots of goodness hiding there.
/Users/xxx> /Applications/djangostack-1.0-6/use_djangostack bash-3.2$ which python /Applications/djangostack-1.0-6/python/bin/python bash-3.2$ python Python 2.5.1 (r251:54863, Sep 11 2008, 12:40:30) [GCC 4.0.0 20041026 (Apple Computer, Inc. build 4061)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import MySQLdb >>> bash-3.2$ python /Applications/djangostack-1.0-6/apps/django/bin/django-admin.py startproject testproject bash-3.2$ cd testproject bash-3.2$ ls __init__.py manage.py settings.py urls.py bash-3.2$
Caution: There was one other small configuration issue I needed to make in the next steps of configuring and synchronizing MySQL not covered in the books or [yet] in the README.txt file, and that was to ensure your Django project settings.py file contains:
DATABASE_HOST=[Django stack install root]/mysql/tmp/mysql.sock