Whether you’re stepping into the world of programming for the first time or switching to Linux as your development environment, Python is the perfect language to begin with. Known for its simplicity and versatility, Python powers everything from web apps to data science. In this guide, we’ll walk you through installing Python on a Linux system and writing your very first “Hello, World!” program — the classic rite of passage for every coder. Let’s get your terminal talking!
Check If Python Is Already Installed
Open Terminal
- On most Linux systems, press Ctrl + Alt + T to open the terminal.
Check the Python Version
Type this command and hit Enter:
python3 --version
If Python is installed, you’ll see something like:
Python 3.11.5
If you get an error, don’t worry—just follow the next step to install it.
Installing Python on Linux
For Ubuntu/Debian-based systems:
sudo apt update
sudo apt install python3 python3-pip
For Fedora:
sudo dnf install python3 python3-pip
For Arch Linux:
sudo pacman -S python python-pip
Verify pip
After installation, check pip (Python’s package manager):
pip3 --version
You should see something like:
pip 23.2.1 from ...
Install Visual Studio Code (VS Code)
Download VS Code
Click “Download for Linux”. Choose the .deb
or .rpm
file depending on your distro.
Install VS Code
For .deb
(Ubuntu/Debian):
sudo apt install ./<filename>.deb
For .rpm
(Fedora):
sudo dnf install ./<filename>.rpm
Enable Terminal Access
Open VS Code, press Ctrl + Shift + P, and type:
Shell Command: Install 'code' command in PATH
Now you can launch VS Code from terminal using:
code .
Set Up Python in VS Code
Install the Python Extension
- Click the Extensions icon (or press Ctrl + Shift + X)
- Search for “Python”
- Install the one by Microsoft
Select Your Python Interpreter
- Press Ctrl + Shift + P
- Type “Python: Select Interpreter”
- Choose the version you installed
Write & Run Your First Python Program
Create a New File
- Go to File > New File
- Save it as
hello.py
Write Your Code
Paste this into the file:
print("Hello, world!")
Run the Program
- Click the Run button
- Or right-click and choose Run Python File in Terminal
You should see:
Hello, world!
🎉 Congrats—you just ran your first Python program!
Troubleshooting Tips
- Python Not Found in VS Code Use “Python: Select Interpreter” and make sure Python is installed
- pip Not Working Try:bash
python3 -m ensurepip python3 -m pip install package_name
- Terminal Issues in VS Code Go to View > Terminal and click the trash icon to reset
- Multiple Python Versions Use:bash
python3 --version which python3
Uninstall older versions if needed - Virtual Environment Confusion Activate with:bash
source venv/bin/activate
- Syntax Errors Python is picky about spaces! VS Code helps catch these early
Pro Tips for Beginners
Practice by building small scripts like a calculator or to-do list
Keep Python and VS Code updated
Use virtual environments to keep projects organized
Explore Python packages with pip search
or PyPI
