Installing Python

This tutorial will guuide through the installation of Python followed by installing Django and setup PostgreSQl as default database.


Installation on Windows

Prerequisites

A Windows PC with internet.

Step1-Download Python

  • Open any internet browser and go to python.org .

Select your version of interest.(3.x is recommended)

Download page

  • Choose installer for download.

Selection of installer

Step2-Install Python and its components

  • After completion of download open the installer and select install now and Add python to path for installing python components such as pip and adding python to path.

Installation

Progress

Step3-Setting up path and testing environment

  • Wait for installation to complete it may take a while.

  • Now let us check whether the environment is working or not.

Open command prompt and type

python --version

pycheck

  • If you did'nt get version as in above image that means you either did'nt choose add python to path or you went for custom installation.

  • No worries, you can add python to path by yourselves by Go to Control Panel > System and Security > System go for Advanced system setting > Environment Variables and then select path, edit the path by adding C:\Users\ *username*\App Data\Local\Programs\Python\ *Pythonfoldername* if python was installed users folder otherwise add C:\ *Python folder name*.

  • Now python environment works. Lets test with a hello program then. Open notepad and write a hello program as below and save it with .py extension.

print('Hello, Welcome to Python')

program

Now open command prompt at location(press Shift+Mouse Right Click) of .py(python file) file and type python hello.py(in my case). It gives an output as follows.

Hello, Welcome to Python

exe

Congos! :sunglasses: you successfully installed and did set up the Python programming environment in your Computer :clap:.

Installation on Ubuntu

Prerequisites

A Ubuntu machine with internet and root access.

Setting up Pythonhttps://raw.githubusercontent.com/Greycampus/pythondjango/master/assets/

  • We are using non graphical way(using command line) for setting up python in your machine.On both Ubuntu 16.04 and 15.04, you can find terminal application by either clicking ctrl+Alt+t or using the search by pressing ubuntu button.

search

Ubuntu ships with both Python 3 and Python 2 pre-installed. To make sure that our versions are up-to-date, let’s update and upgrade the system with apt-get:

sudo apt-get update
sudo apt-get -y upgrade

Once the process is complete, we can check the version of Python that is installed in the system by typing:

python --version
python3 --version

16.04(customized the profiles of terminal, so don't panic if you see a different coloured terminal)

16.04ver

15.04om

15.04

The output should be similar to above images(the version may vary).

To manage software packages for Python, let’s install pip:

sudo apt-get install -y python3-pip

pip is a package manager that manages the programming packages in developing projects.

we can install new packages using pip by:

pip installpackagename

There are a few more packages and development tools to install to ensure that we have a robust set-up for our programming environment:

sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Congos! :sunglasses: you successfully set up the Python programming environment in your Computer :clap:.