I setup Python and Django using homebrew the easy way. I am going to detail the process now.
Install Python
1 |
brew install python |
The command should first install any dependencies for Python and then install the latest version from source code.
Adding Python to PATH
We need to edit our ~/.bash_profile to add “/usr/local/share/python” to the path variable. I added the following line to my bash profile:
1 |
export PATH=/usr/local/share/python:$PATH |
I reloaded the profile by issuing:
1 |
source ~/.bash_profile |
This makes the python tools and toys accessible from my terminal.
Install MySQL Module
It’s recommended that you already have “mysql” installed from brew to build the mysql module. I already had it installed so it was a painless installation for me. I just issued the command:
1 |
pip install mysql-python |
Install Django
I am going to keep using the PIP awesomeness! Let’s hit:
1 |
pip install django |
It will install django with any dependencies. You can now invoke the “django-admin.py” command from your terminal. However, I prefer the command be “django-admin”, instead of “django-admin.py”. So I created the following alias in my ~/.bash_profile:
1 2 |
#Django alias django-admin=/usr/local/share/python/django-admin.py |
Isn’t it simple? 😀