How to Install Python in Ubuntu

Python is an easy-to-use programing language, however, to write Python codes in a Ubuntu system, you first need to download and the set it up.

If you’re looking to install Python in Ubuntu Linux, you’ve come to the right place. Python is a powerful, versatile programming language that is widely used by developers around the world for everything from web development to data science. Installing Python in Ubuntu is a relatively simple process, and in this blog post, we’ll walk you through the how to install Python in Ubuntu Linux process.

How to Install Python in Ubuntu

How to Install Python in Ubuntu

Python is an easy-to-learn language that is both powerful and flexible. It has a simple syntax, which makes it easy to read and write. It is also highly extensible, which means that it can be used to create libraries and frameworks. This makes it a great choice for beginners, as they don’t need to learn complex syntax to get started. It is also an object-oriented language, which means that it is organized around objects rather than actions. This makes it a great choice for problem-solving, as it allows programmers to easily manipulate and interact with objects.

The steps for Ubuntu install Python 2 is quick and easy, and can be done through the command line or the Ubuntu Software Center. Before you proceed with the steps to how to install python 3 on Ubuntu, follow the prerequisites to check if your PC is capable of installing it.

Prerequisites

  • Make sure you have Ubuntu 18.04 or Ubuntu 20.04
  • You must have a user account with sudo privileges
  • You must have access to command-line (CtrlAltT)
  • Also ensure that your environment is configured to use Python 3.8

Method 1: Install Python in Ubuntu from Deadsnakes PPA

The Deadsnakes PPA is an official repository for Python packages that are maintained by the Ubuntu community. This section will show you how to install python in ubuntu from Deadsnakes PPA.

1. Before getting started, you need to make sure you have the necessary packages installed. To do this, open a terminal window, and run the following command:

sudo apt-get install software-properties-common

sudo apt-get install software-properties-common

2. Once you have the necessary packages installed, you can add the Deadsnakes PPA to your list of software repositories. To do this, run the following command:

sudo add-apt-repository ppa:deadsnakes/ppa

3. Next, you need to update your system to make sure that the new repository is included. To do this, run the following command:

sudo apt-get update

4. Now that the repository is added and updated, you can install Python from Deadsnakes PPA. To do this, run the following command:

sudo apt-get install python3.6

sudo apt-get install python3.6 | How to Install Python in Ubuntu

5. Once the installation is complete, you can verify that Python is installed by running the following command:

python3.6 –version

Also Read: Fix Command Failed With Error Code 1 Python Egg Info

Method 2: Install Python in Ubuntu from Source Code

Installing Python in Ubuntu from source code is a great way to ensure you have the most up-to-date version of the language, as well as the most flexibility when it comes to customizing the installation. How to install Python 3 on ubuntu a relatively simple process, but it does require some technical knowledge and a few steps.

1. Firstly, update your local repository list by executing the following command in the terminal window.

sudo apt update

2. Then, install all the supporting dependencies on your PC with APT by using this command.

sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

3. Next, make a new directory on your system to save the Python source files:

mkdir /python && cd /python

4. Download the Python source code from the official FTP server.

wget 

5. Then, extract the TGZ file by using the below command.

tar -xvf Python-3.11.0a7.tgz

6. Next, use the command ./configure followed by make and make install to compile the code and install it.

Note: This may take some time, depending on the size of the source code and the speed of your computer, so be patient. Once it’s done, you’ll have a fully-functional version of Python installed in Ubuntu.

7. Finally, you should check to make sure that the Python installation is working properly. To do this, type python in the terminal window. If everything is working properly, you should see the Python interactive shell open. You can also type python -V to check the version of Python that is installed.

Method 3: Install Python Using APT

In this method, you will learn how to install Python using APT (Advanced Packaging Tool) on Ubuntu systems. APT is a package manager for Debian-based systems that makes it easy to install, upgrade, and remove software packages.

1. Before you begin, it is important to make sure that your system is up to date. To do this, open a terminal window and type the following commands:

sudo apt-get update
sudo apt-get upgrade

2. To install Python using APT, you will need to open a terminal window and type the following command:

sudo apt-get install python

3. Once the installation is complete, you can check the version of Python installed on your system by typing the following command:

python --version

4. If you need a specific version of Python, you can use the following command:

sudo apt-get install python=<version>

Note: Replace <version> with the version of Python you want to install. For example, to install Python 3.8, you would type the following command:

sudo apt-get install python=3.8

5. Once the installation is complete, you can check the version of Python installed on your system by typing the following command:

python --version

6. You can also install additional packages for Python using APT. For example, to install the NumPy package, you would type the following command:

sudo apt-get install python-numpy

7. Once all of the packages have been installed, you can begin using Python. To do this, open a terminal window and type the following command:

python

This will open an interactive Python shell where you can type commands and see the results.

Frequently Asked Questions (FAQs)

Q1. Can Python 3 install on Ubuntu?

Ans. Yes, Python 3 can be installed on Ubuntu. The easiest way to install Python 3 on Ubuntu is to use the apt package manager. You can also download the source code from the official Python website and compile it yourself.

Q2. Do I need to install pip?

Ans. No, pip is already installed if you are using Python version 2.7.9 or newer, or Python 3 version 3.4 or newer.

Q3. Does Python automatically install pip?

Ans. No, Python does not automatically install pip. Pip is a package manager for Python and must be installed separately.

Recommended: 

We hope, you have understood How to install python in Ubuntu. With a few simple steps, you can now have Python running on your Ubuntu system. For any comments or queries, feel free to reach us via the comments section.

Leave a Comment

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