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).
- Install homebrew by running the following:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
This will show you if everything is gucci. If it's not cool, then attempt to fix the issues.brew install python3
This should install both Python 3 and pip3.sudo pip3 install Django
That should install django. If you want a specific version of Django just useDjango=1.8.x
- Now run
python3
andimport 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
.
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...
- 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
. - Open either cmd or powershell and run
python --version
, if returns2.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.
- Run
pip3 install django
like the above instructions, and your system should begin to install django. - Now run
python3
andimport django
. You should get no output and be good to go.