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

How to install Python on Linux?

Last Updated : 15 May, 2024
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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.

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.

Python 3.13 Installation in Linux

Step 1: Updating and Upgrading Operating System

Before Installing Python 3.12 with APT in Linux(Ubuntu) we have to Update Operating System. To update the operating system use the command mentioned below.

sudo apt update
updating OS

updating OS

To Upgrade the operating system use the command mentioned below.

sudo apt upgrade
Upgrading OS

Upgrading OS

Step 2: Adding the deadsnakes PPA to your system’s package sources

Deadsnakes PPA is a popular and trusted repository maintained by the Ubuntu community. It offers the latest versions of Python, including development and unstable releases, which may not be available in the official Ubuntu repositories.The purpose of using the deadsnakes PPA is to gain access to the most recent Python versions, as the official Ubuntu repositories often lag behind in providing the latest releases. By adding the deadsnakes PPA to your system’s package sources, you can install the latest Python versions directly from this repository.

Install the prerequisite for adding PPAs:

This command installs the software-properties-common package, which provides a tool called add-apt-repository. This tool is used to add new package repositories (like the deadsnakes PPA) to your system’s sources list.

sudo apt install software-properties-common -y
installing perquisite

installing perquisite

Adding deadsnakes PPA:

This command adds the deadsnakes PPA to your system’s package sources list. The ppa:deadsnakes/ppa part specifies the PPA location, which is hosted on Launchpad (a software collaboration platform used by Ubuntu and other distributions).

sudo add-apt-repository ppa:deadsnakes/ppa

Adding deadsnakes PPA

Adding deadsnakes PPA

Adding deadsnakes PPA

Adding deadsnakes PPA

We have to update apt after we have installed repository.

Sudo apt update

Step 3: Installing Python3.13 in Linux

Now we can install python3.13 using command mentioned below.

sudo apt install python3.13
Installing python 3.13 on Linux

Installing python 3.13 on Linux

Step 4: Verifying the Installation of python3.13 in Linux

To verify the installation of python3.13 in linux we can simply display the version of python3.13 by using the command mentioned below.

python3.13 --version
2024-05-15_15-10

verifying the

Step 5: Installing PIP

If you have used apt to install python3.13 then you might have to install pip3.13 version manually , to do so command is mentioned below.

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.13
installing pip3.13 for python3.13

installing pip3.13 for python3.13

Step 6: Verifying Installation of PIP3.13

To verify the installation of pip3.13 in Linux we can use the command mentioned below.

2024-05-15_15-37

verifying

Install Python on Linux – FAQs

How can I check if Python is already installed on my Linux system?

You can check if Python is pre-installed on your Linux distribution by opening the terminal and running the following commands:

python --version  # For Python 2.x
python3 --version # For Python 3.x

If Python is installed, these commands will display the respective version numbers. If not, you’ll typically get a “command not found” error.

What is the recommended way to install Python on Ubuntu/Debian-based distributions?

The recommended way to install Python on Ubuntu and other Debian-based distributions is to use the Advanced Packaging Tool (APT) package manager. You can install Python 3 with the following command:

sudo apt install python3

This command will install the latest available version of Python 3 from the official Ubuntu repositories.

How can I install a specific version of Python on Linux?

To install a specific version of Python, you may need to add a third-party repository like the deadsnakes PPA for Ubuntu/Debian. After adding the repository, you can install the desired Python version with a command like:

sudo apt install python3.9  # For Python 3.9

Replace “3.9” with the version number you want to install.

What is pip, and how do I install it on Linux?

pip is the package installer for Python, which allows you to install and manage external Python packages and libraries. On most Linux distributions, you can install pip for Python 3 with the following command:

sudo apt install python3-pip

Alternatively, you can download the get-pip.py script and run it with the respective Python version:

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

How can I install Python packages in a virtual environment on Linux?

It’s generally recommended to use virtual environments to isolate Python packages and dependencies for different projects. You can create and activate a virtual environment on Linux using the venv module:

python3 -m venv myenv       # Create a virtual environment named 'myenv'
source myenv/bin/activate # Activate the virtual environment

With the virtual environment activated, you can install packages using pip without affecting the system-wide Python installation.

Conclusion

Getting the latest Python3 version up and running on Linux like Ubuntu involves a few easy steps. First, you update the system packages. Then, you add the deadsnakes PPA repository to access the newest Python releases. After that, you can simply install the desired Python3 version using the apt package manager. Finally, you download and install the pip package installer for the specific Python3 version you installed. Once you verify that both Python3 and pip are installed correctly, your system is ready to start using Python3 for coding, scripting, or running Python applications. Following these straightforward steps allows you to quickly set up the latest Python3 environment on your Linux machine.



Similar Reads

How to Download and Install Python Latest Version on Linux?
Python is a widely-used general-purpose, high-level programming language. This article will serve as a complete tutorial on How to download and install Python latest version on Linux Operating Systems. On every Linux system including following OS, Ubuntu Linux Mint Debian openSUSE CentOS Fedora and my favourite one, Arch Linux. You will find Python
3 min read
How to Install Python Pycharm on Linux?
Prerequisite: Python Language Introduction Python is a widely-used general-purpose, high-level programming language. It was initially designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was mainly developed for emphasis on code readability, and its syntax allows programmers to express concepts in fewer lines of code
2 min read
How to Install OpenCV for Python in Linux?
Prerequisite: Python Language Introduction OpenCV is the huge open-source library for computer vision, machine learning, and image processing and now it plays a major role in real-time operation which is very important in today’s systems. By using it, one can process images and videos to identify objects, faces, or even the handwriting of a human.
2 min read
How to Install Numdifftools in Python on Linux?
Numdifftools is a Python-based toolkit that solves numerical differentiation issues in one or more variables automatically. To produce the most accurate outcome, finite differences are exploited adaptively in conjunction with a Richardson extrapolation mechanism. This library is cross-platformed, so it can work with Windows, Linux, and even with ma
2 min read
Python - Install Paramiko on Windows and Linux
The high-level python API starts with the creation of a secure connection object. To have more direct control and pass a socket to transport to start remote access. As a client, it's authenticating using a user credential or private key, and checking the server’s host key. Paramiko is a Python library that makes a connection with a remote device th
1 min read
How to Install python-nmap Library on Linux?
Python-Nmap is a network mapper that is exceptionally vital in handling security auditing and discovering the network. It exists as an open-source project; thus it is available for free. All the core operating systems support Python-Nmap. However, the binary packages are only available for Windows, Linux, and Mac OS X. Nmap is essential in port sca
5 min read
How to Install midi, midi_maniulation for Python on Linux?
In this article, we are going to see how to install midi Python on Linux. MIDI is an acronym for Musical Instrument Digital Interface. MIDI is a way to connect devices that make and control sounds. And there is a python framework for this midi manipulation. Using this python framework, we can read MIDI files from disk, build new MIDI streams, proce
2 min read
How to Install python-kinterbasdb on Linux?
In this article, we will be looking at the stepwise procedure to install the python-kinterbasdb for Python in Linux. KInterbasDB is a Python DB API 2.0 module for the relational databases Firebird and Interbase. It also exposes most of the native client API of the database engine, including two-phase commit, server-side events, and an administrativ
2 min read
How to Install MySQLdb module for Python in Linux?
In this article, we are discussing how to connect to the MySQL database module for python in Linux. MySQLdb is an interface for connecting to a MySQL database server from Python. It implements the Python Database API v2.0 and is built on top of the MySQL C API. Installing MySQLdb module for Python on Linux: Follow the below steps to install Python
2 min read
How to Install python-gadfly in Linux?
In this article, we will be looking at the stepwise procedure to install the python-gadfly for Python in Linux. Gadfly is a relational database management system written in Python. Gadfly is a collection of Python modules that provides relational database functionality entirely implemented in Python. It supports a subset of the standard RDBMS Struc
2 min read
How install Setuptools for Python on Linux?
Setuptools is a package development process library that extends the Python standard library distutils to make it easier to package Python projects (distribution utilities). It contains the following features: Package and module declarations in PythonMetadata from the distribution packageHooks for testingInstallation of the projectPlatform-specific
2 min read
How to Install python 'bottle package' on Linux?
py-bottle is a lightweight micro-framework for developing small web apps and it supports request dispatching (Routes) with URL parameter support, templates, a built-in HTTP Server, and adapters for several third-party WSGI/HTTP-server and template engines are all included in a single file with no dependencies except the Python standard library. In
2 min read
How to Install Python-arrow on Linux?
Arrow is a Python library for performing tasks with date and time. It presents a sensible and human-friendly approach to creating, manipulating, formatting, and converting dates, times, and timestamps. Arrow allows easy creation of date and time instances with timezone awareness. So, in this article, we will be installing Arrow library in Python on
1 min read
How to Install Python-Amara on Linux?
Amara is a Python library for XML processing in a Python environment, designed to balance the native idioms of Python with the native character of XML. Amara is a cross-platformed library that works on Windows, Linux, and macOS. So in this article, we will be installing the Amara package in Python on Linux operating system by using the PIP manager.
1 min read
How to Install "Python-PyPDF2" package on Linux?
PyPDF2 is a Python module for extracting document-specific information, merging PDF files, separating PDF pages, adding watermarks to files, encrypting and decrypting PDF files, and so on. PyPDF2 is a pure python module so it can run on any platform without any platform-related dependencies on any external libraries or packages. So, in this article
2 min read
How to Install python-docx on Linux?
Word documents include formatted text wrapped in three object levels: Run objects at the lowest level, Paragraph objects at the intermediate level, and Document objects at the top level. As a result, we are unable to work with these documents using standard text editors. However, we may use the Python-Docx package to manage these word documents in
2 min read
How to Install Python-logging module on Linux?
A programmer's backpack should include a logging library. It can aid in the development of a better knowledge of a program's flow and the discovery of scenarios that you may not have considered when designing. Because most third-party Python libraries employ logging, you may combine your log messages with those from those libraries to create a unif
2 min read
How to Install Python-web2py package on Linux?
Web2py is a Python package that helps web developers to create dynamic online content. Although a web developer may construct a form from scratch if necessary, Web2py is meant to assist decrease tiresome web development activities like building web forms from scratch. So, in this article, we'll use the PIP manager to install the Web2py Python packa
2 min read
How to Install PyBullet package in Python on Linux?
PyBullet is a Python library based on the Bullet Physics SDK for physics simulation and robotics. It works with a variety of sensors, actuators, and terrains. Basically, this is a fantastic library for anyone who is just getting started with robotics or physics modeling. So, in this tutorial, we'll use the PIP manager to install the PyBullet packag
2 min read
How to Install Python-pyautogui package on Linux?
PyAutoGUI allows your Python programs to automate interactions with other apps by controlling the mouse and keyboard. The API was created with simplicity in mind. PyAutoGUI is a cross-platformed library that works on Windows, macOS, and Linux and runs on Python 2 and 3. We will install the PyAutoGUI package in Python on the Linux operating system i
2 min read
How to Install Python-pyzmail package on Linux?
Pyzmail is a high-level Python mail library. It has methods and classes that make reading, writing, and sending emails easier. There's no reason why managing emails with Python should be more complex than with popular mail clients like Outlook or Thunderbird. The intricacy of the MIME structure and MIME encoding/decoding is hidden by the pyzmail pa
2 min read
How to Install Vaex in Python on Linux?
Vaex is a Python module that assists us in accomplishing this and makes dealing with massive datasets a breeze. It's notably useful for Out-of-Core DataFrames that are sluggish (similar to Pandas). It can quickly view, analyze, and compute on large tabular datasets with low memory utilization. In this article, we will look into the steps of install
2 min read
How to Install Yara in Python on Linux?
YARA is a malware research tool that aids in the identification and classification of malware samples. You may use YARA to make descriptions of malware families based on textual or binary patterns found on samples from those families. This utility is officially accessible in the Python environment as a package. It's now available through the PyPi p
2 min read
How to Install maskpass package in Python on Linux?
Maskpass is a Python package that may be used to conceal user passwords while they are being entered. When programs interface with users via terminal, the Maskpass modules provide a safe solution to handle password prompts. Maskpass is a cross-platform library that works on Windows, Linux, and Mac OS X. In this article, we'll show you how to instal
2 min read
How to Install Imapclient in Python on Linux?
IMAPClient is a Python-based, easy-to-use, and comprehensive IMAP client library. Although IMAPClient makes use of the imaplib module from the Python standard library, it has its own API. IMAPClient officially supports Python versions 2.7 and 3.4 through 3.9. So, in this article, we'll learn how to install the IMAPClient Python package on a Linux m
1 min read
How to Install Turtle in Python on Linux?
Turtle is a Python language library that is similar to the virtual canvas through which we can design pictures and attractive shapes. Most of the usage of this library is done for the children to introduce to the world of programming. New programmers can learn programming in a fun and interactive way. In this article, we will be installing the Turt
2 min read
How to Install PyGTK in Python on Linux?
PyGTK module allows GUI development using Python. It is an open-source and cross-platform library that provides an interface to the GIMP toolkit (GTK) in python. It is accessed through the PyGObject package which provides bindings for GObject-based libraries like GTK. Note that in python3, PyGTK and GTK are the same things. It is a great alternativ
2 min read
How to Install Nose in Python on Linux?
The nose is a Python package essentially needed for automation framework testing. Basically, Nose generates uni-test modules that will help to execute the testing result much better. Also, Nose provides another advantage in that it will auto-discover the test cases. Based on the test case result it will generate test case documentation also. The no
3 min read
How to Install Requests in Python - For Windows, Linux, Mac
Requests is an elegant and simple HTTP library for Python, built for human beings. One of the most famous libraries for Python is used by developers al over the world. This article revolves around how one can install requests library of Python in Windows/ Linux/ macOS using pip. Install Requests Module in Python in Window For installing requests in
4 min read
Install Pytorch on Linux
In this article, we are going to see how you can install PyTorch in the Linux system. We are using Ubuntu 20 LTS you can use any other one. To successfully install PyTorch in your Linux system, follow the below procedure: First, check if you are using python’s latest version or not. Because PyGame requires python 3.7 or a higher version, make sure
2 min read
Article Tags :
Practice Tags :