How to Install Python 3.10 on Linux Mint 21 or 20

Python 3.10, released on October 4, 2021, is a significant milestone in the evolution of the Python programming language. It serves as a bridge from past versions to newer advancements, balancing established features with fresh innovations. This guide will focus on demonstrating the process to install Python 3.10 on Linux Mint 21 or Linux Mint 20.

Key Features of Python 3.10:

  • Structural Pattern Matching: A major highlight is the introduction of the match statement, a powerful tool for pattern matching. This feature enables embedded patterns in data structures, improving both code clarity and maintainability.
  • Parenthesized Context Managers: This update simplifies the use of multiple context managers. By grouping them in a single statement, Python 3.10 reduces code complexity and enhances readability.
  • Enhanced Tracebacks: Debugging is more efficient with detailed tracebacks, pinpointing the exact line numbers where errors occur. This precision aids developers in quickly identifying and addressing issues.
  • Syntax Innovations: The inclusion of new syntax elements, such as the case statement and the “parent” keyword, enriches the language’s expressiveness. The “parent” keyword, in particular, provides a clearer alternative to “super()” in class inheritance.
  • Refined Error Messages: Error diagnostics in Python 3.10 are more informative, offering contextual guidance and suggestions. This enhancement streamlines the debugging process, making it more user-friendly.
  • Performance Improvements: Python 3.10 introduces various optimizations, leading to faster function calls and attribute access. These changes collectively contribute to the speedier execution of Python programs.
  • Deprecated Features: This version also phases out certain outdated elements, guiding developers towards modern Python coding practices.

Moving forward from its rich history and distinctive features, the next sections will guide you through the installation process of Python 3.10 on Linux Mint.

Import Python PPA on Linux Mint 21 or 20

Step 1: Update Linux Mint Before Python 3.10 Installation

Ensure your Linux Mint system is up-to-date to avoid any conflicts during the Python 3.10 installation. Use the command below to update your system:

sudo apt update && sudo apt upgrade

Step 2: Import the PPA for Python 3.10 onto Linux Mint

To import the stable PPA for Python 3.10, which will allow you to install the latest stable versions of Python, execute the following command in your terminal:

sudo add-apt-repository ppa:deadsnakes/ppa -y

This command adds the Deadsnakes PPA to your system.

Refreshing the APT Sources List

After adding the Python PPA, it’s essential to refresh your system’s APT sources list. This step updates your system’s package database, ensuring it recognizes the newly added Python 3.10 package.

To refresh the APT sources, use the command below:

sudo apt update

This action fetches the latest package information from all configured sources, including the newly added PPA, making Python 3.10 available for installation on your system.

Install Python 3.10 on Linux Mint 21 or 20

Install Python 3.10 on Linux Mint via APT Command

Having successfully imported the Python PPA and updated your system’s APT sources list, you’re now ready to install Python 3.10 on Linux Mint.

To do this, open your terminal and execute the following command:

sudo apt install python3.10

This command will download and install Python 3.10 from the Deadsnakes PPA you added earlier.

Verifying Python 3.10 Installation

Once the installation process is complete, it’s a good practice to verify that the correct version of Python has been installed.

Run the following command to check the installed Python version:

python3.10 --version

This command displays the version of Python 3.10 that is now installed on your system, confirming the successful installation.

Optional Extras for Enhancing Python 3.10

Python 3.10 offers various optional modules that can be installed to enhance your development experience. These modules include:

  • Debug Module: For advanced debugging capabilities.
sudo apt install python3.10-dbg
  • Developer Module: Essential for Python development.
sudo apt install python3.10-dev
  • VENV Module: For creating isolated Python environments.
sudo apt install python3.10-venv
  • Distutils Module: Useful for distributing Python modules.
sudo apt install python3.10-distutils
  • lib2to3 Utility Module: Aids in Python 2 to Python 3 code conversion.
sudo apt install python3.10-lib2to3
  • DBM.GNU Module: Provides GNU’s database support for Python.
sudo apt install python3.10-gdbm
  • Tkinter Module: Enables GUI development with Python.
sudo apt install python3.10-tk

To streamline the process, you can install all these extras simultaneously using the following command:

sudo apt install python3.10-full

Test Python 3.10 Shell on Linux Mint 21 or 20

Opening the Python 3.10 Shell

With Python 3.10 installed on your Linux Mint system, the next step is to test the Python shell to ensure its proper functionality. The Python shell is an interactive environment that allows you to write and test Python code in real-time.

To open the Python 3.10 shell, execute the following command in your terminal:


This command initiates the interactive Python 3.10 shell. Here, you can directly input Python commands, experiment with new Python 3.10 features, or test snippets of your code.

If Python 3.10 is not your default Python version (for instance, if Python 3.12 is set as default), use the python3.10 command to specify the version. However, if Python 3.10 is your default version, simply using python3 may suffice.

Exiting the Python 3.10 Shell

To exit the Python 3.10 shell after completing your tasks or testing, you have two options:


This command will close the Python 3.10 shell and return you to the Linux Mint terminal.

Alternatively, you can use the keyboard shortcut Ctrl+D to exit the shell.

Install Pip with Python 3.10 on Linux Mint 21 or 20

Install Python PIP via APT Command

Pip, the Python Package Installer, is a vital tool for managing Python packages and libraries, significantly enhancing your Python 3.10 experience on Linux Mint. For most users who have installed Python 3.10 via the Python PPA repository, Pip is usually installed by default.

To manually install Pip, if it’s not already installed, use the following APT command:

sudo apt install python3-pip

This command installs Pip for Python 3.10, allowing you to manage Python packages easily.

Downloading and Installing PIP Manually on Linux Mint

In cases where the above method encounters issues, you can opt to install Pip manually:

First, download the file using the wget command:


This command downloads the script, which is used for the manual installation of Pip.

After downloading the file, run the following command to install PIP:


Running this script installs Pip on your system, ensuring you can manage Python packages.

Upgrade PIP to the Latest Version

After installing Pip, it’s recommended to upgrade it to the latest version. This ensures you have all the latest features and security updates.

Use the following command to upgrade Pip:

python3 -m pip install --upgrade pip

This command updates Pip to its most recent version, offering improved performance and compatibility with newer Python packages.

Verifying the Installed Version of PIP on Linux Mint

To confirm the successful installation and version of Pip, execute the following command:

pip --version

This command displays the currently installed version of Pip, verifying that Pip is correctly set up on your Linux Mint system with Python 3.10.

Basic PIP Commands with Python 3.10 on Linux Mint 21 or 20

Installing a Python Package

After installing and verifying Pip, you’re ready to use it to manage Python packages. To install a Python package, which can range from libraries to development tools, use the following command:

pip install package_name

In this command, replace package_name with the actual name of the Python package you wish to install. For example, if you want to install NumPy, a popular package for numerical computations, you would use:

pip install numpy

This command instructs Pip to download and install the specified package, along with its dependencies, from the Python Package Index (PyPI).

Upgrading a Python Package

Keeping your Python packages updated is crucial for accessing the latest features and security patches. To upgrade an existing package to its latest version, use this command:

pip install --upgrade package_name

Here, package_name should be replaced with the name of the package you intend to upgrade. For example, to upgrade NumPy, you would use:

pip install --upgrade numpy

This command checks for the latest version of the specified package and upgrades it if a newer version is available.

Removing a Python Package

If a Python package is no longer required, it’s good practice to uninstall it to keep your environment clean and efficient. To uninstall a package, the following command is used:

pip uninstall package_name

Again, replace package_name with the name of the package you wish to remove. For instance, to uninstall NumPy, the command would be:

pip uninstall numpy

This command removes the specified package from your Python environment, freeing up resources and decluttering your workspace.

Python Virtual Environment on Linux Mint with Python 3.10

Creating a Virtual Environment

Virtual environments in Python provide an isolated space for each project, allowing you to manage project-specific dependencies without affecting the global Python setup. This is especially useful when working on multiple projects with differing requirements.

To create a new virtual environment using Python 3.10, execute the command:

python3.10 -m venv my_venv

Here, my_venv is a placeholder. Replace it with your chosen name for the virtual environment. This command creates a directory with the name you specify, containing a complete, isolated Python environment.

Activating the Virtual Environment

Once the virtual environment is created, the next step is to activate it. Activation of the virtual environment adjusts the path and environment variables, ensuring that you use the Python interpreter and libraries specific to this environment.

To activate it, use the command:

source my_venv/bin/activate

Replace my_venv with the name of your virtual environment. You’ll notice that your command prompt changes to indicate that you are now working inside the virtual environment. This change in the command prompt is a visual confirmation that any Python commands you execute are now confined to this environment.

Deactivating the Virtual Environment

After completing your work in the virtual environment, it’s important to deactivate it to return to the global Python environment. This step ensures that any further Python commands you run are no longer limited to the virtual environment.

To deactivate, run:


This command exits the virtual environment and reverts your command prompt and environment settings to their global defaults.

Managing Python 3.10 on Linux Mint 21 or 20

Update Python 3.10 on Linux Mint

Maintaining an updated Python installation is crucial for security and functionality. To update Python 3.10 on Linux Mint, proceed with the following steps:

Update APT Package List:

Begin by updating your APT package list to ensure you have the latest repository information. Use this command:

sudo apt update

This command refreshes your local package index with the latest updates and versions available from all configured sources, including Python 3.10.

Upgrade Python 3.10:

If an update for Python 3.10 is available, it will be listed along with other available package upgrades. Execute the following command to upgrade:

sudo apt upgrade

This command upgrades all updatable packages, including Python 3.10, to their latest versions.

Removing Python 3.10 from Linux Mint

In situations where Python 3.10 is no longer needed, it can be removed safely from your system using the APT package manager. Follow these steps to remove Python 3.10:

sudo apt remove python3.10

This command uninstalls Python 3.10 from your Linux Mint system. It is important to note that removing Python may affect applications and scripts that depend on it.

Remove Python PPA

Lastly, if you have only installed Python 3.10 from the PPA and not utilizing it for any other Python versions, you can safely remove it with the following commands:

sudo add-apt-repository --remove ppa:deadsnakes/ppa -y

Alternating Python 3.10 as Default Version on Linux Mint 21 or 20

Adding Symbolic Links for Python Versions

When managing multiple Python versions on your Linux Mint system, it’s often necessary to designate one as the default. This process involves creating symbolic links for each Python version. Symbolic links act as pointers or shortcuts to the actual Python executable files, allowing easier version management.

To set up these links, execute the following commands, adjusting them according to the Python versions you have installed:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.7 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 3
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.9 4
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 5
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 6
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 7

Each command associates a Python version with a priority number, where a higher number indicates a higher priority. In this list, Python 3.12 is assigned the highest priority (7), while Python 2.7 has the lowest (1).

Switching to a Different Python Version

To change the default Python version on your system, use the update-alternatives command. This tool provides a simple way to manage different software versions on Linux. Run the following command:

sudo update-alternatives --config python

This command lists all Python versions set up with symbolic links and their corresponding selection numbers. Choose the number that corresponds to Python 3.10 to set it as the default. For instance, if Python 3.10 is option 5, you would type ‘5’.

The command’s output confirms the selection:

update-alternatives: using /usr/bin/python3.10 to provide /usr/bin/python (python) in manual mode

Setting Python 3.10 as the default version ensures that when you run Python scripts or use the python command, the system uses Python 3.10 unless otherwise specified. This approach offers flexibility in managing different Python versions, enabling seamless transitions between projects with varying requirements.


To wrap up, we’ve navigated through the essential steps of enhancing your Python development journey on Linux Mint, focusing on Python 3.10 for developers or users needing this specific version, from installation to managing multiple versions with ease. This guide has covered the crucial aspects to get you up and running.

1 thought on “How to Install Python 3.10 on Linux Mint 21 or 20”

Leave a Comment