ubuntu - tips & tricks

install python pip and django on ubuntu

Django is a free and open source web application framework, written in Python, which follows the Model–View–Controller (MVC) architectural pattern.  In this article I will provide you instructions to install python pip and django on ubuntu linux to create a development site .

Install  python package management system

pip is a package management system used to install and manage software packages written in Python. Pip is a replacement for easy_install, and is intended to be an improved Python package installer. It is an easy to use command-line interface which makes installing python package as easy as easy as issuing one command:

To install pip open a terminal window type in:

Install python virtual environment

What is VirtualEnv

Virtualenv is a very simple tool, which enables you to creating virtual python environments. It does not enable you to create full virtual environments,  where you can simulate entire production environments,  it only allows you to have separate python executable file, along with a separate set of libraries.

Virtualenv allows you to control which packages are used on a particular project by cloning your main Python. This helps you to to ensure you never install a python package globally, which my result in library conflicts etc. Working inside virtual environments ensures you only install project dependencies inside the projects that require them. Projects with conflicting dependencies can happily co-exist on the same machine.

Create directory for python projects
I usually create a directory on my computer for my python projects. You can name this directory anything you like, and can literally place it where ever you like. However, I usually just create a directory on my home folder, and usually call it dev.

Change your terminal directory to the dev directory

Find where your python 3.4 installed, in case python has been installed elsewhere on your box. Usually it is installed at /usr/bin/python3.4

Create django project virtual environment

Change your directory , and now create a directory and project structure for our django project, and we’ll use python3.4 for the project. change directory to you new
in this instance we have created a project name of demo

We now need to activate the project, i.e tell python we are going to be working in this directory

We can now install django, into our virtual environment

This will install the latest django framework, if you want to install a specific version of the django all you need to do is use the == and the version number required i.e.

This will install the django to your virtual environment.
Start your django project
This command will invoke the django-admin.py script which will set up a new Django project with what_ever_your_project_name_project is for you. A kind of a django developer convention is to add _project, in order to signify the directory where the code files are kept, but there is no hard and fast rule and this is entirely up to you.

You can now try using manage.py script, to run your application issuing the following command
This will instruct django to initiate its lightweight development server. You should see the output in your terminal window
If open the link in your web browser You should see a page similar to;

At the time of writing this post the django documentation did not provide sufficient information about PIP and VirtualEnv and I thought I would provide this information for anyone who may have been struggling with this.

Go to Django Project Documentation

Gary Woodfine

Freelance Full Stack Developer at threenine.co.uk
Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.

Affiliate Disclaimer

Disclosure: Please note that some of the links included in the blog posts are affiliate links, which means I will earn a commission if you decide to make a purchase.

I only include affiliate links to products, services and companies that I have personal experience and have actually used. I only recommend them because they are helpful and useful, not because of the small commissions I make if you decide to buy something.

Please do not spend any money on these products unless you feel they are relevant, suitable and will help you achieve your goals.

Buying anyone of these products and the commisions earned will not make me an overnite multi millionaire, but they will help to cover the hosting costs and compensate for the countless hours and effort I put in to create meaningful and valuable free content I provide to help others succeed.

You've also undoubtedly noticed that I also use various advertising networks - unless of of course you're using an Ad blocker, this is also an attempt to reduce my monthly deficit I experience in providing free relevant, valuable and on occassion insightful content for the benefit of others.

I only really make some money if people click on the ads, unless of course you consider 1c per 1000 impressions real money!

Bear in mind just how many impressions I need to make before I can cover my £20 hosting costs a month!

If you are using an adblocker and guilt stricken you can of course donate using any of the buttons below, but I won't be holding my breath.

Buy me a coffeeBuy me a coffee