Installing python 3 on Ubuntu

Saksham Lakhera
2 min readSep 21, 2020

Installing pip for Python 3

Ubuntu 18.04 ships with Python 3, as the default Python installation. Complete the following steps to install pip (pip3) for Python 3:

  1. Start by updating the package list using the following command:

sudo apt update

2. Use the following command to install pip for Python 3:

sudo apt install python3-pip

3. The command above will also install all the dependencies required for building Python modules.

4. Once the installation is complete, verify the installation by checking the pip version:

pip3 --version

5. The version number may vary, but it will look something like this:

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

OR

Installing with get-pip.py

To install pip, securely 1 download get-pip.py by following this link: get-pip.py. Alternatively, use curl:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

Then run the following command in the folder where you have downloaded get-pip.py:

python get-pip.py

Installing Python 3

Step 1:- Install ppa

This PPA contains more recent Python versions packaged for Ubuntu. Install ppa by running the following command.

$ sudo add-apt-repository ppa:deadsnakes/ppa

Step 2:- Update packeges

Now, update your packages by running the following command.

$ sudo apt-get update

Step 3:- Upgrade python 2.x to python 3.x

Before install 3.7, we should have to install python 3.6 by running the following command.

$ sudo apt-get install python3.6
$ sudo apt-get install python3.7

PiP installation

Install pip by running the following command.

$ sudo apt install python3-pip

Set priority

$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 2

Now, you can use python 2.7, 3.6 and 3.7 in your machine.

--

--

Saksham Lakhera

Exploring and Analysing life with all my tech and soft skills.