We over here at TLS Web Solutions snagged ourselves yet another productive and time-saving piece of machinery — a MacBook Pro. While it ran smooth, we wanted to setup a Django dev enviroment pretty quickly and had a couple issues during that process.
Thankfully, Seanlin.me had just what the doctor order, a quick and easy Django dev setup guide for the Mac OS X.
Below are the steps are his setups that you can follow to get environment for Django up and running in no time.
- Python 2.7
- Django 1.3
- HomeBrew – a package manager for Mac OSX that allow you to install UNIX tools.
- GCC Package Installer – XCode replacement
- Pip – Package install for Python
- PIL – Python Imaging Library
- Virtualenv – virtual environment for Python
Copy and paste following codes inside the terminal.
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
Now you will have working installation of Homebrew. To test it out type
in your terminal. If you see the list of example usage, your HomeBrew installation is a success.
UNIX Package Installer
If you have XCode installed on your system, then ignore this step. XCode is recommend for installing Python but not required. You can try to install Python without XCode by choosing an installer below.
Download and install –
For OS X 10.7 Lion: https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7.pkg
For OS X 10.6 Snow Leopard: https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.6.pkg
Just run following command in your terminal.
brew install git
Run the command
brew install readline sqlite gdbm
after completion, run following command
brew install python --universal --framework
Pip allows you to manage and install Python packages. Run the following command in your terminal.
Virtualenv allow you to have isolated Python environments for development. Run following command –
pip install virtualenv
To create the isolated environment to install and run Django, create a new folder for your project and browse into it,
mkdir new_directory_name cd new_directory_name
then run following command to start a new virtual environment –
virtualenv environment_name --no-site-packages
Change the “environment_name” to whatever name you want to set. Then run following two commands to activate virtualenv –
Again, replace the “environment_name” with the one you created above. Now you will have extra “(environment_name)” in your terminal.
Run following command to install Django –
pip install django
You now have a fully working environment for Django development. If you want MySQL support as well, run following two commands to install MySQL server and MySQL-python
brew install mysql pip install http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz?use_mirror=cdnetworks-us-2
Just run following command to install PIL
pip install PIL
Starting Django Project
Browse to your project directory from command line and activate your virtualenv if it hasn’t
Remember to replace “environment_name” with the one you created. Once your virtualenv has been activated, run following command to start your Django project
django-admin.py startproject project_name
Replace the “project_name” with your own and you are good to start developing your Django apps.
THANKS AGAIN SEANLIN.ME! Click here to view the original instructions.