Sunday, 11 February 2018

Install Python 3 and Set Up a Local Programming Environment then install Django locally on Ubuntu 16.04

This article is about installing python 3 virtual environment on Ubuntu 16.04. If you are looking to set up a python 3 development environment, this  tutorial will help you.

First install python 3 by run these commands in the terminal
sudo apt-get install python3.5

Then install pip3 the python package manager by running
sudo apt-get install python3-pip

Then install virtualenv package
sudo pip3 install virtualenv

Then create a directory named my_proj which is our project name in your home directory. Then open a terminal window in that directory. Run the following command to create a virtual environment
virtualenv -p python3 env

Then run this command to activate the virtual environment
source env/bin/activate

Our virtual environment is activated now. To check it run
which python3

It will give the result    /home/sukesh/sukesh/python/my_proj/env/bin/python3

To install Django 2 run this
pip install Django

Note that pip, and python commands can be used in our virtual environment instead of pip3 and python3.

 Run this to check django
python -m django --version

It will give result   2.0.5

Create a sample project by run this. Don't forget the trailing dot(.)
django-admin startproject my_proj .

Our project is created now. Run this to create an app
django-admin startapp my_app

Now we need to add the created app to our project. For that open my_proj/my_proj/, then add 'my_app' to the INSTALLED_APPS section. Our INSTALLED_APPS will looks like this

You have finished. To start the development server run
python runserver

Our server has started now. To check this open this url in any browser:-

Watch this video tutorial (Click the gear icon and select video quality to 1080p HD, then click the full screen button for good quality)

Thank You


  1. Thanks for sharing amazing information about python .Gain the knowledge and hands-on experience in python online training


Search This Blog