How to install Python on Ubuntu is a basic task that often comes up after a fresh system install or before running scripts, packages, and learning projects. In most cases, the simplest approach is to use Ubuntu’s standard package manager and then confirm that everything works correctly.
Check whether Python is already installed
Checking the installed Python version on Ubuntu shows whether you actually need a separate installation and helps avoid changing the system interpreter unnecessarily.
Open a terminal and run:
- python3 –version — shows the installed Python 3 version.
- which python3 — shows the path to the executable if it is available.
If the command returns a version number, Python is already present on the system. If you see a message saying the command is missing, move on to installation.
Install Python with apt
Installing Python on Ubuntu with apt is the most reliable option for most users because it uses the official system repositories.
Run these commands one by one:
- sudo apt update — refreshes the package list.
- sudo apt install python3 — installs Python 3.
After the installation finishes, check the result with python3 –version. If the version appears without errors, the installation was successful.
If the system says the package is already installed, no extra action is needed. In that case, go straight to version checking and any additional tools you may need.
Add pip and useful components
Installing pip on Ubuntu is necessary if you plan to install Python libraries for projects, automation, or testing.
For a basic setup, it is also useful to install package-management tools:
- sudo apt install python3-pip — adds the pip package manager.
- sudo apt install python3-venv — enables virtual environments.
Verification is simple: pip3 –version should display a version number and an installation path. If pip does not start, repeat the installation or check whether a different Python version is being used.
When you need a separate Python version
A separate Python version on Ubuntu is needed when a project requires a specific release that is not available in the standard system repository.
In that situation, it is safer to leave the system Python unchanged and create a separate environment for the project. That reduces the risk of breaking system tools that depend on the built-in version.
- For a single project, venv is usually the best choice.
- For multiple Python versions, a dedicated version manager or a third-party repository can work, but only if you understand the trade-offs.
After installing a new version, check it with python3.x –version, then run a test script or open the interactive shell to confirm that the correct version is active.
Run a quick post-installation check
A post-installation Python check on Ubuntu should confirm that the interpreter starts, packages can be installed, and the environment works without errors.
Run a short test:
- python3 — opens the interactive console.
- print("hello") — checks that code executes correctly.
- exit() — leaves the console.
If the console does not open or the command is not found, close the terminal, open it again, and repeat the check. If the problem continues, verify that the package was not installed in a partial environment or a restricted session.

