The Wayback Machine - https://web.archive.org/web/20240118171640/https://www.geeksforgeeks.org/how-to-install-python-on-linux/
Open In App
Related Articles

How to install Python on Linux?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Before we start with how to install Python3 on Linux, let’s first go through the basic introduction to Python. Python is a widely used general-purpose, high-level programming language. Python is a programming language that lets you work quickly and integrate systems more efficiently. There are two major Python versions- Python 2 and Python 3. Both are quite different.

Prerequisite: Python Language Introduction

Getting Started with Python

Python is a lot easier to code and learn. Python programs can be written on any plain text editor like Notepad, Notepad++, or anything of that sort. One can also use an online IDE for writing Python codes or can even install one on their system to make it more feasible to write these codes because IDEs provide a lot of features like intuitive code editor, debugger, compiler, etc. To begin with, writing Python Codes and performing various intriguing and useful operations, one must have Python installed on their System.

Check if Python already exists

Most of the Linux OS has Python pre-installed. To check if your device is pre-installed with Python or not, just go to the terminal using Ctrl+Alt+T.
Now run the following command:

For Python2

python --version

For Python3.x

python3.x --version

If Python is already installed, it will generate a message with the Python version available.

Check-python-version-for-linux

Beginning Python installation

For almost every Linux system, the following command could be used to install Python directly:

$ sudo apt-get install python3.8

Getting Started

We will start our installation by writing the password as mentioned in the below picture that gives the permission to perform further operations.

Getting-Started

Assigning DiskSpace

Generally, it asks for additional diskspace and we generally continue by typing Y and then enter.

Assigning-DiskSpace

Fetching and Installing Packages

It’s a process in which required packages and modules are fetched and installed automatically. It happens on it’s own when we give the permission to assign the diskspace.

Fetching-and-Installing-Packages

Getting through the installation process

Getting-through-the-installation-process

Finished Installation

Here, the required installation is completed.

Finished-Installation

To verify the installation enter the following commands in your Terminal.

python3.8

Run our First Python Program

Let’s consider a simple Hello World Program.

Python3




# Python program to print
# Hello World
 
print("Hello World")


Output:

Hello-World-Python-Linux

Don't miss your chance to ride the wave of the data revolution! Every industry is scaling new heights by tapping into the power of data. Sharpen your skills, become a part of the hottest trend in the 21st century.
Dive into the future of technology - explore the Complete Machine Learning and Data Science Program by GeeksforGeeks and stay ahead of the curve.

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 15 Nov, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads
Complete Tutorials