Command To Install Python In Ubuntu

Command To Install Python In Ubuntu

Reading time1 min
#Python#Linux#Programming#Ubuntu#CommandLine#PythonInstaller

Mastering the Command Line: Installing Python on Ubuntu Efficiently and Correctly

Forget vague tutorials: this guide skips GUI distractions and walks you through the exact command-line commands that every serious Ubuntu user must know to install Python cleanly—no guesswork, no extra fluff.


Python is everywhere—from scripting quick tasks to powering full-scale applications. For developers and sysadmins running Ubuntu, having Python properly installed via command line not only ensures a reliable environment but also keeps your system clean and ready for any project.

In this post, I’ll show you exactly how to install Python on Ubuntu from the terminal, step by step. Whether you want the default stable version or need a specific release, this guide has got you covered.


Why the Command Line?

While Ubuntu’s Software Center or other GUI tools might be tempting, they often install unnecessary packages or older versions of Python by default. Using the command line:

  • You get full control over what’s installed.
  • Can automate installations easily.
  • Avoid guesswork.
  • Ensure a minimal yet functional setup optimized for your needs.

1. Verify if Python Is Already Installed

Before installing, let's check what’s already on your system:

python3 --version

Ubuntu generally comes with Python 3 pre-installed. You might see something like:

Python 3.8.10

If that version fits your needs, great! If not, proceed with installing/upgrading.


2. Update Your Package Lists

To make sure you get the latest available Python packages from Ubuntu repositories:

sudo apt update

Never skip this step to prevent frustrating outdated package errors.


3. Install Python 3

The current default Python version on recent Ubuntu LTS releases is usually Python 3.x (x varies).

To install the default Python 3 package:

sudo apt install python3

Check the installation was successful:

python3 --version

You should now have a working Python 3 interpreter accessible as python3.


4. Install Additional Essential Packages

Most Ubuntu environments do not link python to python3 by default anymore, which can cause confusion when running scripts or commands that use python. To address this cleanly without interfering system-wise:

  • Install the python-is-python3 package if you want the python command to point to python3.
sudo apt install python-is-python3
  • Or explicitly use python3 everywhere (highly recommended for clarity).

Additionally, installing pip (the package installer for Python) is crucial for managing third-party modules.

Install pip for Python 3 with:

sudo apt install python3-pip

Confirm with:

pip3 --version

5. Optional: Install Specific Versions of Python (e.g., 3.10)

Ubuntu’s default repos may lag behind recent releases. To install newer versions such as Python 3.10 or later:

  1. Add the deadsnakes PPA (a popular repository for newer Python versions):
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
  1. Install desired version (replace 3.x with your requirement):
sudo apt install python3.10 python3.10-venv python3.10-distutils

Check version:

python3.10 --version

Make sure to use virtual environments (venv) and specify interpreter paths accordingly when using multiple versions.


Summary of Essential Commands

PurposeCommand
Update package listssudo apt update
Install default Python 3sudo apt install python3
Map python command to python3sudo apt install python-is-python3
Install pip for Python 3sudo apt install python3-pip
Add deadsnakes PPAsudo add-apt-repository ppa:deadsnakes/ppa
Install specific version (e.g., 3.10)sudo apt install python3.10 python3.10-venv

Final Tips: Keeping It Clean & Efficient

  • Always prefer using explicit commands like python3 instead of ambiguous ones.
  • Use virtual environments (python -m venv envname) to isolate project dependencies.
  • Regularly run sudo apt update && sudo apt upgrade to keep system packages secure and up-to-date.
  • Avoid mixing installation methods — stick with APT packages or use tools like pyenv or directly build from source if absolute control is needed.

By mastering these command-line basics, you’ll have a solid foundation to develop, deploy, or administer Ubuntu systems with confidence using Python—installed efficiently and correctly every time.

If you found this guide helpful or want more tips on Linux and development workflows, feel free to subscribe or leave a comment below!