Check existing Python
Most Linux distributions come with Python pre-installed. Let’s check: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:- Ubuntu/Debian
- Fedora/RHEL/CentOS
- Arch/Manjaro
- openSUSE
- Alpine
Verify installation
Check that Python and pip are installed:Test Python
- Start Python:
- You’ll see the Python prompt:
- Try a simple command:
- Exit Python:
- Type
exit()or pressCtrl + D
- Type
Troubleshooting
Permission denied
Permission denied
For system packages: Always use For pip packages: Install in user space:Best practice: Use virtual environments to avoid permission issues entirely.
sudo:python3: command not found
python3: command not found
Python isn’t installed. Install it using your package manager:
pip3: command not found
pip3: command not found
pip isn’t installed. Fix it.
Outdated Python version
Outdated Python version
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
Option 1: Use deadsnakes PPA (Ubuntu/Debian):
externally-managed-environment error
externally-managed-environment error
Modern Linux prevents pip from installing system-wide. Solutions:
Use virtual environments (recommended):Install in user directory:Use pipx for applications:
Use virtual environments (recommended):
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