Python is a must-have tool for coding, automation, and tech projects. Installing it on Linux is quick and easy. Follow this simple guide to get Python running on your system in minutes.
Check if Python is Already Installed
Most Linux systems come with Python pre-installed. Let’s check!
Open your terminal and type:
python3 --version
If you see a version number (like Python 3.10.6), Python is ready! If not, follow the steps below.
Install Python Using Your Package Manager
Linux uses “package managers” to install software. Pick your system type below.
For Debian/Ubuntu (APT):
- Update your system:
sudo apt update
- Install Python:
sudo apt install python3
For Fedora/CentOS (DNF):
- Update your system:
sudo dnf update
- Install Python:
sudo dnf install python3
Wait for the installation to finish. Done!
Install the Latest Python from Source
Need the newest Python version? Build it from source.
- Install tools needed to compile Python:
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libsqlite3-dev libreadline-dev libffi-dev curl libbz2-dev
(For Fedora, use sudo dnf groupinstall "Development Tools"
)
- Download Python’s source code:
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
- Extract the file:
tar -xvf Python-3.12.0.tgz
- Build and install Python:
cd Python-3.12.0
./configure --enable-optimizations
make -j 8
sudo make install
This takes 5-10 minutes. Be patient!
Verify Python is Working
Check if Python installed correctly. Type in the terminal:
python3 --version
You should see the version number.
Test Python with a simple program:
python3 -c 'print("Hello, Linux!")'
If it shows Hello, Linux!, you’re all set!
Final Thoughts
You’ve installed Python on Linux! Start coding, build apps, or automate tasks.
Need help? Comment below! Loved this guide? Share it with friends.