Search code examples
pythondjangoeasy-installmysql-python

Problems getting Django up and running on OSX


First, I'm following the tutorial on the Django Poll application on their site and have hit a few road blocks.

I've installed Python 2.7 and Django 1.3

Created a new project with

django-admin.py startproject myproject

I got mysql up and running and entered the credentials in settings.py

Then when I try to run

python manage.py syncdb

it puked ... http://pastie.org/2294709

Then when I installed Mysql-python

easy_install mysql-python

Success! ...

Searching for MySQL-python
Best match: MySQL-python 1.2.3
Adding MySQL-python 1.2.3 to easy-install.pth file

Using /Library/Python/2.6/site-packages
Processing dependencies for MySQL-python
Finished processing dependencies for MySQL-python

so I try again

python manage.py syncdb

Still pukes the same message as above

Am I missing Something?


Solution

  • jondavidjohn's comment is spot on: you will have no end of confusion with multiple versions of Python on the Mac. There are some things you can do to deal with this.

    1. Stick with 2.6

    2. Convert to Lion, which has 2.7

    3. Add an alias to your shell environment to invoke version 2.7 with $ python. In my bash_profile, I have "alias python='/usr/local/bin/python'"

    4. Be sure to set your PYTHONPATH variable to the site packages directory that corresponds to the version of Python that you're using, such as PYTHONPATH=/usr/local/Cellar/python/2.7.1/lib/python2.7/site-packages

    5. Make sure you know which version of easy_install is operative; many module problems arise from assuming that easy_install will use the same site-packages version for everything. Not true always. Every different Python bin directory has its own version of easy_install (or pip, by preference) which will use the corresponding site packages directory.

    6. Don't try to run Django under Python 3.x

    7. Don't try to get rid of the OS version of Python; it will break your installation because software update sometimes relies on it.

    8. Once you're past this hurdle, there are some other parts of getting the sample poll app in Django to run that I had problems with, so I put my experience at https://github.com/technocrat/Writing-your-first-Django-app