Skip to main content

Check existing Python

Most Linux distributions come with Python pre-installed. Let’s check:
If you see a recent Python 3 version, you’re ready! Most modern Linux distributions include Python 3.
Linux uses python3 to distinguish from the older Python 2. Some distributions let you use just python, but python3 always works.

Install or update Python

Choose your Linux distribution below:

Update package lists

Install Python and essential tools

Install development headers (for compiling packages)

For the latest Python version

If your distribution doesn’t have the latest Python:

Verify installation

Check that Python and pip are installed:
You should see version numbers for both.

Test Python

  1. Start Python:
  1. You’ll see the Python prompt:
  1. Try a simple command:
  1. Exit Python:
    • Type exit() or press Ctrl + D

Troubleshooting

For system packages: Always use sudo:
For pip packages: Install in user space:
Best practice: Use virtual environments to avoid permission issues entirely.
Python isn’t installed. Install it using your package manager:
pip isn’t installed. Fix it.
Your distribution has an old Python. Options:

Option 1: Use deadsnakes PPA (Ubuntu/Debian):
Option 2: Compile from source:
Option 3: Use pyenv for version management

Modern Linux prevents pip from installing system-wide. Solutions:

Use virtual environments (recommended):
Install in user directory:
Use pipx for applications:

Next steps

Great! Python is ready on your Linux system. Let’s set up your development environment.

Continue to VS Code introduction

Install and configure Visual Studio Code