How to Install Python on Linux & Run Your First Hello World Program

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!

  • On most Linux systems, press Ctrl + Alt + T to open the terminal.

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.

sudo apt update
sudo apt install python3 python3-pip
sudo dnf install python3 python3-pip
sudo pacman -S python python-pip

After installation, check pip (Python’s package manager):

pip3 --version

You should see something like:

pip 23.2.1 from ...

👉 code.visualstudio.com

Click “Download for Linux”. Choose the .deb or .rpm file depending on your distro.

For .deb (Ubuntu/Debian):

sudo apt install ./<filename>.deb

For .rpm (Fedora):

sudo dnf install ./<filename>.rpm

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 .
  • Click the Extensions icon (or press Ctrl + Shift + X)
  • Search for “Python”
  • Install the one by Microsoft
  • Press Ctrl + Shift + P
  • Type “Python: Select Interpreter”
  • Choose the version you installed
  • Go to File > New File
  • Save it as hello.py

Paste this into the file:

print("Hello, world!")
  • 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!

  • Python Not Found in VS Code Use “Python: Select Interpreter” and make sure Python is installed
  • pip Not Working Try:bashpython3 -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:bashpython3 --version which python3 Uninstall older versions if needed
  • Virtual Environment Confusion Activate with:bashsource venv/bin/activate
  • Syntax Errors Python is picky about spaces! VS Code helps catch these early

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

Installing python on Linux

Leave a Comment

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

Scroll to Top