Install Python on Ubuntu 16.04 [ 3 steps and 2 Minute Tutorial]

Install Python on Ubuntu 16.04 [ 3 steps and 2 Minute Tutorial]


Python has become a versatile programming language nowadays. Also python is widely used in machine learning language.

In this article we will how to Install Python on Ubuntu 16.04 server.

Python was initially developed in 1991 and named after the Comedy group Monty Python.

The creators of python Made it very easy to code.

Even newbie can understand and start coding within short time.

This has got very grace towards the Python language for all developers.

Since machine learning and many other web application purposes, the python is used at the back end.

Especially many programmers use ubuntu operating system for their programming.

This made us to give a guide for people to install python on ubuntu 16.04 server.

Let us the requirement for python installation on ubuntu 16.04 server.


  • Create sudo non root user and initial server setup as mentioned in this guide.

Thats all. Now, let us look into the procedure.

  1. First, we will install python on ubuntu
  2. We will create virtual environment for python
  3. Then, we will create a python program for testing purpose.

1. Install Python Ubuntu 16.04

Ubuntu 16.04 has come with Python 2 and python 3 in its package repository. So, it is easy to install them with

basic command lines.


Before that, we will once again ensure that our system package is up to date.

Now, check whether the system has python 3 installed with the version check command.

You should get these following output.

We need to manage the python software package, for that we will install pip using the below command.

When you work on a project, you will need many python packages to install on the go. For that, you can use pip to install the python packages using simple commands.

Just replace the above command with your required package name.

For example, we can install the Numpy package using the below command.

The next step is to setup virtual environment for python.

2. Setup Python Virtual Environment

Python Virtual environment is one essential thing for developers.

Because, a developer can work on multiple projects on a same server.

Each of the project requires different packages and dependencies to work on.

We can keep using many dependencies for all the projects. It will make the software creation more complex.

So, here we can setup a virtual environment for each of our projects.

Each of this virtual environment only contains the required dependencies for the project.

These virtual environment simple directories and act as an unique environment for each project due to the script inside those folders.

Those scripts only calls and uses those dependencies for those projects.

We need pyenev commands to create the virtual environment. For that we have to install the venv module from the python 3 package library.

To install pyenev, use this below command.

After the installation, our next step is to create the directories for python programming environment. To do this, we will create environments directory using mkdir comamnd.

Use the below command to create the directories.

We have changed the current location our directory to create environment inside the directory.

To create environment, use this below command.

The pyvenv will create  a new directory. To view that, use ls command.

You should get the following output.

These files are required to keep the project files and dependencies from the server local environment.

This way, we can avoid conflicts and achieve version control over the projects.

Also, all of the projects will have corresponding dependencies to work on.

Ubuntu 16.04 has a share directory for Python Wheels.

The python wheels reduces the number of time a software has to be compiled for the execution.

This way the production can be increased and resource utilization is achieved.

To enable use the python wheel in shared library, use this below command.

Now, the you will be switched to the my_env and you can see prefix of your environment name in your prompt.

the prompt will look like this.

Now, whatever the program you develop under this environment will only use packages, settings and dependencies inside this environment.

3. Create Test Program for Python

To make sure that the environment is working, we will create a small program.

Use the below command to create new file to write a program in it.

Add the below line in the file and save.

This program will give output Hello World when executing it.

Press Ctrl+X and press Y to save and close.

To run the program, use the below command.

You should get the following output now.

Once, you finish the task, you can return to your home environment by typing deactivate.


If you have errors, questions, commands, then leave them in the commands.

Share this article and make sure to subscribe the tutorial news letter.



Leave a Reply

Your email address will not be published. Required fields are marked *