Skip to content
ilmydunya

Explore the Latest IT Updates & Blogs

ilmydunya

Explore the Latest IT Updates & Blogs

  • Home
  • Linux
  • Windows
  • Ubuntu
  • About Us
    • Disclaimer
    • Terms of Use
    • Privacy Policy
  • Contact Us
  • Home
  • Linux
  • Windows
  • Ubuntu
  • About Us
    • Disclaimer
    • Terms of Use
    • Privacy Policy
  • Contact Us
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
ilmydunya

Explore the Latest IT Updates & Blogs

ilmydunya

Explore the Latest IT Updates & Blogs

  • Home
  • Linux
  • Windows
  • Ubuntu
  • About Us
    • Disclaimer
    • Terms of Use
    • Privacy Policy
  • Contact Us
  • Home
  • Linux
  • Windows
  • Ubuntu
  • About Us
    • Disclaimer
    • Terms of Use
    • Privacy Policy
  • Contact Us
Close

Search

  • https://www.facebook.com/
  • https://twitter.com/
  • https://t.me/
  • https://www.instagram.com/
  • https://youtube.com/
How To Install Python on Linux
LinuxUbuntu

How To Install Python on Linux

By Ahsan
June 10, 2026 6 Min Read
0

As one of the most popular programming languages in the world, Python is a great option for aspiring software developers, web developers, data scientists, or even people who want to automate repetitive tasks or build AI (artificial intelligence) programs.

Python and Linux are a great match. While most distributions of Linux come with a version of Python pre-installed, programmers often need to install the most up-to-date version to carry out certain programming projects. So learning how to Install Python on Linux is a great skill to know as a beginner and an even greater skill as a professional.

This guide will help you learn various ways to Install Python on multiple distributions of Linux, including Linux Ubuntu, Linux Debian, Linux Fedora, Linux CentOS, Linux Rocky, Linux Alma, and Linux Arch. This guide will also help you learn how to confirm the installation was a success, how to upgrade Python, and how to troubleshoot Python installation problems.

Table of Contents

Toggle
  • Python and Linux
  • Verify the Existence of Python
    • Check Python 3 Version
    • Alternative Command
    • Example Output
  • Installation of Python on Linux via Package Manager
  • Installing Python on Ubuntu
    • Step 1: Update Packages
    • Step 2: Install Python
    • Step 3: Verify Installation
  • Installing Python on Debian
    • Step 1: Update Packages
    • Step 2: Install Python
    • Step 3: Check Python Version
  • Installing Python on Fedora
    • Step 1: Update Fedora
    • Step 2: Install Python
    • Step 3: Verify Installation
  • Installing Python on CentOS
    • Installing Python
    • Verify Python Installation
  • Installing Python on Rocky Linux and AlmaLinux
  • Installing Python on Arch Linux
    • Step 1: Update the System
    • Step 2: Install Python
    • Step 3: Verify Installation
  • Installing the Latest Version of Python on Linux
    • Step 1: Install Some Dependencies
    • Step 2: Get the Python Source
    • Step 3: Prepare the Build
    • Step 4: Python Source Code
    • Step 5: Install Python
  • Install Pip on Ubuntu or Debian
  • Creating Python Virtual Environments
    • Install Virtual Environment Package
    • Create a Virtual Environment
    • Activate the Virtual Environment
    • Deactivate the Virtual Environment
  • Updating Python on Linux
    • To Update Python on Ubuntu
    • To Update Python on Fedora
    • To Update Python on Arch Linux
    • Check Python Version After Update
  • Checking Your Python Installation
    • Checking the Version of Python
    • Check the Interactive Shell
    • Test Python with Hello World
    • Exit Python Shell
  • Common Python Installation Errors and Fixes
    • Python Command Not Found Error
    • Pip Command Not Found Error
    • Permission Denied Error
    • Multiple Python Versions
  • Advantages of Installing Python on Linux
    • Performance
    • Strong Community Support
    • Ideal for Servers
    • Better Security
  • Best Practices After Installing Python
  • Conclusion

Python and Linux

Because of Linux’s popular usage among system administrators, Python’s usefulness as an automation scripting language is evident. Combine this with Python’s readability and simplicity, and it’s no wonder that Python is the programming language of choice for beginners.

Verify the Existence of Python

It is prudent to verify the existence of Python in your Linux system prior to installation.

Check Python 3 Version

This involves the execution of the command:

python3 --version

Alternative Command

Alternatively, you may run:

python --version

Example Output

An example of the command output may be:

Python 3.12.3

The existence of a version number indicates that Python is already present on your system. Should you encounter a command not found type of error, you will be required to install Python.

Installation of Python on Linux via Package Manager

Installation of Python on Linux via Package Manager


Utilizing the package manager in your Linux distribution is the simplest method for installing Python.

Installing Python on Ubuntu

For Ubuntu, the APT package manager will be used.

Step 1: Update Packages

Begin with an update of the packages:

sudo apt update

Step 2: Install Python

Now, install Python with the command:

sudo apt install python3

Step 3: Verify Installation

To verify the installation, run:

python3 --version

The installed version of Python will be displayed.

Installing Python on Debian

The installation of Python on Debian will follow the same commands as that of Ubuntu.

Step 1: Update Packages

sudo apt update

Step 2: Install Python

sudo apt install python3

Step 3: Check Python Version

The version can be checked with:

python3 --version

This is the recommended method, as Debian will install a stable version, tested by the Debian maintainers.

Installing Python on Fedora

Fedora uses the DNF package manager.

Step 1: Update Fedora

The commands will be:

sudo dnf update

Step 2: Install Python

sudo dnf install python3

Step 3: Verify Installation

Verify installation with:

python3 --version

Typically, Fedora will provide a newer version of Python than many other distributions.

Installing Python on CentOS

Python may be installed on CentOS via YUM or DNF, depending on the version.

Installing Python

For newer RHEL versions, you can use:

sudo yum install python3

or:

sudo dnf install python3

Verify Python Installation

To verify, use:

python3 --version

Installing Python on Rocky Linux and AlmaLinux

To install on Rocky Linux/AlmaLinux, use:

sudo dnf install python3

To verify use:

python3 --version

Cross Linux Distros Enterprise make it easy to install Python.

Installing Python on Arch Linux

Arch users can use pacman to install Python.

Step 1: Update the System

To update the system, use:

sudo pacman -Syu

Step 2: Install Python

To install Python, use:

sudo pacman -S python

Step 3: Verify Installation

To verify the install, use:

python --version

Arch offers the latest stable release of python.

Installing the Latest Version of Python on Linux

Releases can be older than the latest Python release, and developers may need to use the latest Python version due to dependencies with modern libraries and frameworks.

Step 1: Install Some Dependencies

For a Debian/Ubuntu system, use the following to install the required dependencies:

sudo apt update
sudo apt install software-properties-common build-essential

Then install wget and curl:

sudo apt install wget curl

Step 2: Get the Python Source

Head to the Python homepage to get the latest version. Example:

wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz

Then extract the tar, then cd into it:

tar -xf Python-3.13.0.tgz
cd Python-3.13.0

Step 3: Prepare the Build

Use the following command to prepare the Python source code with optimizations:

./configure --enable-optimizations

Step 4: Python Source Code

Then use the following to compile the code:

make -j $(nproc)

This command can take a while depending on the hardware specs available.

Step 5: Install Python

You can use the following command to install Python with out replacing the System Python:

sudo make altinstall

Then Python 3.13 should be installed:

python3.13 --version

Lastly, pip is Python’s package manager and is available on Linux.

Install Pip on Ubuntu or Debian

  • Use this command:
sudo apt install python3-pip
  • Check Installation
pip3 --version
  • Example pip3 Output
pip 24.0

Creating Python Virtual Environments

Virtual environments allow project isolation by encapsulating dependencies.

Install Virtual Environment Package

Use the command to install the relevant package:

sudo apt install python3-venv

Create a Virtual Environment

To create a virtual environment:

python3 -m venv myproject

Activate the Virtual Environment

Use the environment:

source myproject/bin/activate

The virtual environment should now be reflected in the terminal.

Deactivate the Virtual Environment

Deactivate the virtual environment:

deactivate

Updating Python on Linux

To improve the performance and security of the system, it is good to update the version of Python.

To Update Python on Ubuntu

sudo apt update
sudo apt upgrade

To Update Python on Fedora

sudo dnf upgrade

To Update Python on Arch Linux

sudo pacman -Syu

Check Python Version After Update

After the update, check the version of Python:

python3 --version

Checking Your Python Installation

After installing Python, check whether the installation was successful.

Checking the Version of Python

python3 --version

Check the Interactive Shell

To check the interactive shell:

python3
Should output:
>>>

Test Python with Hello World

A test print of the popular first program:

print("Hello World")

Should output:

Hello World

Exit Python Shell

To exit:

exit()

Common Python Installation Errors and Fixes

Python Command Not Found Error

If you see:

Error:

python3: command not found

Then run:

sudo apt install python3

Pip Command Not Found Error

If you see:

Error:

pip3: command not found

Then run:

sudo apt install python3-pip

Permission Denied Error

If you see:

Error:

Permission denied

Then run:

sudo command

If you have:

Multiple Python Versions

Multiple Python Versions

Run:

ls /usr/bin/python*

Use the required version:

python3.11

or

python3.13

Advantages of Installing Python on Linux

Some of the many advantages include:

Performance

Linux provides a stable and efficient environment for running Python applications.

Strong Community Support

Documentation and support for both Python and Linux are available from their respective vast communities.

Ideal for Servers

Python applications run on Linux in many web servers and cloud platforms.

Better Security

Linux protects Python projects and applications with enhanced security features.

Best Practices After Installing Python

The following best practices help maintain a clean development environment with Python on Linux:

  • Python should always be updated.
  • Projects should always be in a virtual environment.
  • Packages should be installed with Pip.
  • System Python should be left unmodified.
  • Projects should be backed up.
  • Learn the basics of package management.
  • And, always use Git or another version control system.

Help keep a development environment clean and professional by following these guidelines.

Conclusion

Installing Python on Linux is one of the first steps you need to learn as a developer of Python. Installation is simple and Linux distributions such as Ubuntu, Debian, Fedora, CentOS, Rocky Linux, AlmaLinux, or Arch Linux install Python readily, even for beginners.

The easiest means of installing Python on Linux is using the package manager included with your distribution. If you want the latest features, you can compile from the Python source code. After installing, remember to install Pip, manage your virtual environments, and upgrade your installations of Python.

Using the methods in this guide will lead to a comprehensive Python development environment to use for programming automation, and data science, as well as web development, and numerous other exciting projects.

Tags:

InstallLinuxPython
Author

Ahsan

Follow Me
Other Articles
How to install Nmap on Kali Linux
Previous

How to install Nmap on Kali Linux

No Comment! Be the first one.

    Leave a Reply Cancel reply

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

    Recent Posts

    • How To Install Python on Linux June 10, 2026
    • How to install Nmap on Kali Linux May 26, 2026
    • How to Fix Corrupted Files on Windows 10 May 18, 2026
    • How to Fix a Blue Screen in Windows 10 May 17, 2026
    • How to Manually Update Windows May 16, 2026

    Category

    • iPhone (5)
    • Linux (13)
    • Ubuntu (4)
    • Windows (14)

    Pages

    • About Us
    • Contact Us
    • Disclaimer
    • Privacy Policy
    • Terms of Use

    ilmydunya

    ilmydunya offers the latest IT updates, trends, and expert blogs to keep you informed in the world of technology
    Copyright 2026 — ilmydunya. All rights reserved.