Python is a popular and versatile programming language that can be used for a variety of purposes, such as web development, data analysis, task automation, and more.
In this post, we will learn how to install the Python programming language on Linux, a free and open source operating system.
There are two main ways to install the Python programming language on Linux: using your Linux distribution’s package manager or downloading the source code from the official Python website.
In this post we will look at each of them in detail.
Posts relacionados:
- Como criar um if de uma linha em Python
- Como instalar a ferramenta de linha de comando pipX
- Como criar um aplicativo Flutter com Python e o framework Flet
- Como instalar a linguagem de programação Python no macOS
- Como fazer o deploy do Python Sphinx no Github pages
- Como utilizar Python com o banco de dados Microsoft Access
- Como utilizar Python com o banco de dados SQL Server
- Como utilizar o SQLAlchemy com o banco de dados SQL Server
- Como utilizar o Python com MariaDB e MySQL Connector
- Como utilizar o Python com MariaDB e MariaDB Connector
- Como utilizar o SQLAlchemy com MariaDB e MariaDB Connector
- Como utilizar o SQLAlchemy com MariaDB e MySQL Connector
- Como utilizar o MongoEngine com o banco de dados MongoDB
- Como utilizar Python com o banco de dados MongoDB
- Como utilizar Python com o banco de dados Redis
- Como utilizar Python com o banco de dados SQLite3
- Como utilizar o SQLAlchemy com o banco de dados SQLite3
- Como utilizar o SQLAlchemy com o banco de dados PostgreSQL
- Como utilizar Python com o banco de dados PostgreSQL
- Como utilizar Python com o banco de dados MySQL
- Como utilizar o SQLAlchemy com o banco de dados MySQL
- Tratamento de caracteres utf-8 com Python e a flag -Xutf8
- PySide6 e PyQt6 os bindings para o framework gráfico Qt 6
- PySide6 e PyQt6 na criação de interfaces gráficas com QML
- Instalando várias versões da linguagem Python no Windows
- Como instalar a ferramenta de linha de comando pyenv
- Configurando o banco de dados MySQL no framework Django
- Configurando o banco de dados PostgreSQL no framework Django
- Como instalar a linguagem de programação Python no Linux
- How to install the Python language on Linux
Using the package manager
Most Linux distributions come with a version of Python pre-installed, but the installation may not be complete or it may not be the version you want to use.
📝 To install a specific version of the Python programming language, use the search function in your distribution’s package manager.
Arch Linux
Official website of the Arch Linux Linux distribution.
Type in the terminal:
sudo pacman -S \
python \
python-pip \
python-lsp-server \
tk
🚨 If
sudo
is not configured, use the root account (withoutsudo
) to install the packages.
Chromebook (ChromeOS)
To install the Python programming language on ChromeOS Linux support must be active:
Once Linux support is active on Chrome OS, open the terminal application and run the command:
sudo apt install \
python3 \
python3-dev \
python3-venv \
python3-pip \
python3-tk \
build-essential \
libssl-dev \
libffi-dev \
python3-pylsp \
python-is-python3 \
idle3
📝 Depending on the version of Debian running in the container, it is possible to use the
python3-full
package.
Fedora
Official website of the Fedora Linux distribution.
🚨 Command tested on Fedora 40.
Type in the terminal:
sudo dnf install \
python3 \
python3-devel \
python3-tools \
python3-idle \
python3-pip \
python3-tkinter \
python-lsp-server \
python-unversioned-command
openSUSE Tumbleweed
Official website of the openSUSE Tumbleweed Linux distribution.
Type in the terminal:
sudo zypper install \
python312 \
python312-tk \
python312-idle \
python-python-lsp-server
Ubuntu and derivatives
Official website of the Ubuntu Linux distribution.
🚨 Command tested on Ubuntu 24.04.
Type in the terminal:
sudo apt install \
python3 \
python3-dev \
python3-venv \
python3-pip \
python3-tk \
python3-pylsp \
python-is-python3 \
idle3
📝 Depending on the Ubuntu version, it is possible to use the
python3-full
package.
How to install the Python language from source
Installing the Python programming language using the source code is very simple, but you will need the compilation tools we’ll see below.
Arch Linux
sudo pacman -S \
base-devel
Fedora
sudo dnf group install \
"C Development Tools and Libraries" \
"Development Tools"
openSUSE Tumbleweed
sudo zypper install \
-t pattern \
devel_basis
Ubuntu
sudo apt install \
build-essential
Another way to install the Python programming language on Linux is by downloading the source code from the official Python website and compiling it on your system.
This way allows you to have more control over the Python version and settings, but it also requires more time and technical knowledge.
To download the Python source code, go to https://www.python.org/downloads/ and choose the version you want to install.
Then download the corresponding *.tar.xz
file and save it in a directory of your choice.
Open a terminal and navigate to the directory where you saved the file and extract the file contents with the command:
tar -xvf Python-3.xxtar.xz
🚨 This will create a folder called
Python-3.xx
, wherexx
is the version you downloaded.
Access the folder with the command:
cd Python-3.xx
Now, you need to configure the source code so that it is compatible with your system.
To do this, type:
./configure
This command will check the dependencies needed to compile Python and create a Makefile with the appropriate instructions.
After the command finishes, you can start the Python compilation with the command:
makeup
Wait for the make
command to finish (no errors).
Finally, you can install the Python programming language with the command:
sudo make install
The command will copy the Python programming language files, binaries, and libraries to the appropriate locations on your Linux distribution.
To check the installation, close the terminal, open it again and type the command:
python3 --version
If you have more than one version of the Python programming language installed, run:
python3.x --version
🚨 Replace the
x
with the version you installed. Example 3.11, 3.12, 3.13, etc.
Ready! Now you know how to install the Python programming language on Linux.
I hope this post was useful to you, if you have any questions, please get in touch 😊.