Skip to content

Instantly share code, notes, and snippets.

@JRJurman
Forked from kocsenc/osx-django.md
Last active September 10, 2015 01:27
Show Gist options
  • Save JRJurman/1c42c9964d24ed4d759b to your computer and use it in GitHub Desktop.
Save JRJurman/1c42c9964d24ed4d759b to your computer and use it in GitHub Desktop.
Installing Django

Install Django on OS X or Windows

For OSX

Django can be tricky to install on OS X if you don't use the appropriate tools. I am using OS X 10.10 but any lower version should work.

NOTE: I assume you have NOT tried to install Python 3 in some other way, if so delete as much as you can (DO NOT DELETE PYTHON 2, THIS IS REQUIRED FOR YOUR SYSTEM TO RUN PROPERLY).

  1. Install homebrew by running the following:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. brew doctor This will show you if everything is gucci. If it's not cool, then attempt to fix the issues.
  3. brew install python3 This should install both Python 3 and pip3.
  4. sudo pip3 install Django That should install django. If you want a specific version of Django just use Django=1.8.x
  5. Now run python3 and import django. You should get no output and be good to go.

A word of caution: The online Django tutorial asks you to use python manage.py potato. On a Mac, you will have to run python3 manage.py potato (just add the 3).

I personally like to change the manage.py scripts first line to #!/usr/bin/env python3 and then just run ./manage.py potato.

For Windows

Managing paths and python environments on a non-unix machine (Windows) can be difficult. My recommendation is to install a VM and put Linux on it. Good starters are Fedora, Ubuntu, Elementary OS, Mint. Running a VM on your machine is a good learning experience, and while it introduces it's own set of pain points, the linux command line tools can be very powerful.

If you want to use Windows...

  1. Make sure python is installed on your system. You can find it in the C directory, it will most likely be located in C:\Python34.
  2. Open either cmd or powershell and run python --version, if returns 2.7.x, you'll need to update your environment variables.
  • This can be done hitting the windows key, and typing environment variables.
  • There should an option "edit the system environment variables", go there and hit the Environment Variables button, which should give you options to edit your path variable.
  • Add to the end of PATH the directory to python: C:\Python34;
  • Run python --version again and check that it works.
  1. Run pip3 install django like the above instructions, and your system should begin to install django.
  2. Now run python3 and import django. You should get no output and be good to go.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment