Python is a portable programming language that can be used anywhere its runtime environment is installed .
Django is a Python framework which can be installed on any system which supports Python language .
In this tutorial part we are going to see how to install Python and Django on major available operating systems i.e Windows , Linux and MAC .
Depending on your operating system you may need or may not need to install Python .In Linux and MAC OS Python is included by default ,you may only need to update it if the installed version is outdated .
Installing Python On Windows
Python is not installed by default on Windows so you'll need to grab the official installer from the official Python website at http://www.python.org/download/ . Launch the installer and follow the wizard to install Python just like any other Windows program .
Also make sure to add Python root folder to system path environment variable so you can execute the Python executable from any directory using the command prompt .
Next open a command prompt and type python .You should be presented with a Python Interactive Shell printing the current version of Python and prompting you to enter your Python commands (Python is an interpreted language )
Installing Python On Linux
If you are using a Linux system ,there is a great chance that you already have Python installed but you may have an old version .In this case you can every easily install it via your terminal depending on your Linux distribution .
For Debian based distributions like Ubuntu you can use apt package manager
sudo apt-get install python
This will update your Python version to the latest available version .
For other Linux distributions you should look for equivalent commands to install or update Python which is not a daunting task if you already use a package manager to install packages for your system then you should follow the same process to install or update Python .
Installing Python on MAC OS
Just like Linux , Python is included by default on MAC but in case you have an old version you should be able to update it by going to http://www.python.org/download/mac/ and grab a Python installer for MAC .
Now if you managed to install or update Python on your own system or in case you have verified that you already have an updated version of Python installed on your system let is continue by installing Django .
PIP is a Python package manager which is used to install Python packages from Python Package Index which more advanced that easy_install the default Python package manager that's installed by default when you install Python .
You should use PIP instaed of easyinstall whenever you can but for installing PIP itself you should use easyinstall .So lets first install PIP :
Open your terminal and enter :
$ sudo easy_install pip
You can now install Django on your system using pip
$ sudo pip install django
While you can do this to install Django ,globally on your system ,it's strongly not recommend ,instead you need to use a virtual environement to install packages.
virtualenv is a tool that allows you to work with multiple Python projects with different or the same ( often different and conflicting versions ) requirements , on the same system without any problems by creating multiple and isolated virtual environments for Python packages .
Now lets first install virtualenv using pip :
sudo pip install virtualenv
Or you can install virtualenv before even installing pip from its official website .
In this case you don't need to install pip because it comes installed with virtualenv and gets copied into any virtual environment you create .
Creating a virtual environment
After installing virtualenv you can now create your first virtual environment using your terminal :
$ cd ~/where-ever-you-want $ virtualenv env New python executable in env/bin/python Installing setuptools............done. Installing pip...............done.
Next you should activate your virtual environment :
Now you can install any Python package using pip inside your created virtual environment .
Lets install Django !
After creating a new virtual environment and activating it ,it is time to install Django using pip
$ pip install django
Rest assured that Django is only installed on the activated virtual environment not globally .
As a conclusion lets summarize what we have done .We first installed Python depending on the operating system ,we then installed pip and virtualenv to install packages from PyPI and create isolated virtual environments for multiple Python projects and finally created a virtual environment and installed Django inside this virtual env .