Linux Ubuntu

How to install python on Ubuntu 20.04 LTS

In this blog I tried to install python on Ubuntu 20.04 LTS and I am successful in it. So I share the installation step by step with pictures. If you have any query or question please comment.

Install python in Ubuntu:

First enter command to update:

$ sudo apt update

sudo apt update

Now to install the python package enter the command below:

$ sudo apt install python3-pip

After pushing enter button the following screen appears:

apt-install python
install packaes

After installing the python check the version of the python by typing the following command:

$ sudo python3 -V

See the following Output for result:

python version

Installing and setting the Web development Environment:

Now we have to install the web development package by typing the following command:

$ pip3 install numpy

You can use any other development environment like Django etc…

install numpy

Now install the additional package by entring the following command:

$ sudo apt install -y build-essential libssl-dev libffi-dev pythone3-dev

command entering pacakes
installing additional packages

This will enable you to reserve the specific space for python projects so that every project has its own dependencies and won’t disrupt other

You can set up as many Python programming environments as you would like. Each environment is basically a directory or folder on your server that has a few scripts in it to make it act as an environment.

While there are a few ways to achieve a programming environment in Python, we’ll be using the venv module here, which is part of the standard Python 3 library. Let’s install venv by typing:

$ sudo apt install -y pythone3-venv

With this installed, we are ready to create environments. Let’s either choose which directory we would like to put our Python programming environments in, or create a new directory with mkdir, as in:

$ mkdir environments
$ cd environments

Once you are in the directory where you would like the environments to live, you can create an environment by running the following command:

$ pythone3 -m venv my_env


Essentially, pyvenv sets up a new directory that contains a few items which we can view with the ls command:

$ ls my_env

Output you see:

$ bin include lib pyvenv.cfg share

Together, these files work to make sure that your projects are isolated from the broader context of your server, so that system files and project files don’t mix. This is good practice for version control and to ensure that each of your projects has access to the particular packages that it needs. Python Wheels, a built-package format for Python that can speed up your software production by reducing the number of times you need to compile, will be in the Ubuntu 20.04 share directory.

To use this environment, you need to activate it, which you can achieve by typing the following command that calls the activate script:\

$ source my_env/bin/activate

Your command prompt will now be prefixed with the name of your environment, in this case it is called my_env. Depending on what version of Debian Linux you are running, your prefix may appear somewhat differently, but the name of your environment in parentheses should be the first thing you see on your line:

This prefix lets us know that the environment my_env is currently active, meaning that when we create programs here they will use only this particular environment’s settings and packages.

Creating environment

Creating a “Hello, World” Program

Now that we have our virtual environment set up, let’s create a traditional “Hello, World!” program. This will let us test our environment and provides us with the opportunity to become more familiar with Python if we aren’t already.

To do this, we’ll open up a command-line text editor such as nano and create a new file:

$ sudo nano

Once the text file opens up in the terminal window we’ll type out our program:

print (“hello World!”)

Exit nano by typing the CTRL and X keys, and when prompted to save the file press Y.

Once you exit out of nano and return to your shell, let’s run the program:

The program that you just created should cause your terminal to produce the following output:


To leave the environment, type the command deactivate and you will return to your original directory.

This is how to install the python on Ubuntu 20.04 LTS if you have any suggestion or question please comments below.

4 thoughts on “How to install python on Ubuntu 20.04 LTS

Leave a Reply

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