Linux MintUbuntu Based

How To Install Python on Linux Mint 22

Install Python on Linux Mint 22

In this tutorial, we will show you how to install Python on Linux Mint 22. Python is one of the most popular programming languages in the world, known for its simplicity, readability, and versatility. It is widely used in various fields such as web development, data science, machine learning, and automation.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Python programming languages on Linux Mint 22.

Prerequisites

  • A server running one of the following operating systems: Linux Mint 22.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • While we’ll guide you through the process, a basic understanding of the command line will be beneficial. If you’re new to the CLI, you might want to acquaint yourself with some fundamental commands.
  • An active internet connection.
  • Administrative privileges are essential for installing and configuring software on your system. Ensure that you have superuser or sudo access.

Install Python on Linux Mint 22

Step 1. Update Your Linux Mint System.

To begin, it’s crucial to update your system packages to their latest versions. This step ensures that you have access to the most recent security patches and bug fixes. Open the terminal and run the following command:

sudo apt update
sudo apt upgrade

This command will refresh the package list and notify you of any available updates. Keeping your system up to date is a good practice to maintain the stability and security of your Linux Mint installation.

Step 2. Installing Python.

  • Installing Python Using APT

The Advanced Package Tool (APT) is the package manager for Debian-based distributions like Linux Mint. You can use APT to install Python from the official repositories. Here’s how you can do it:

sudo apt install python3

After installation, verify that Python has been installed correctly by checking its version:

python3 --version

You should see the version of Python that you just installed.

  • Installing Python from Source Code

Sometimes, you might need a specific version of Python that is not available in the repositories. In such cases, you can install Python from the source code. Here’s a step-by-step guide:

Python requires several dependencies to be installed before compiling it from the source. Install these dependencies using the following command:

sudo apt install zlib1g-dev libsqlite3-dev libnss3-dev libssl-dev build-essential libgdbm-dev wget libbz2-dev libffi-dev libncurses5-dev libreadline-dev

Download the source code for the desired version of Python. For this example, we will use Python 3.12.4:

wget https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz

Extract the downloaded source code:

tar -xf Python-3.12.4.tgz

Navigate to the extracted directory and compile Python:

cd Python-3.12.4
./configure --enable-optimizations
make -j 4
sudo make altinstall

Finally, verify that the new version of Python has been installed correctly:

python3.12 --version

Step 3. Using Pyenv to Manage Python Versions.

Pyenv is a powerful tool for managing multiple versions of Python on your system. It allows you to easily switch between different versions of Python and isolate project dependencies.

Install Pyenv using the following command:

curl https://pyenv.run | bash

Update your shell configuration to include Pyenv:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc
source ~/.bashrc

Install the desired version of Python using Pyenv:

pyenv install 3.12.0

Set the global Python version to the newly installed one:

pyenv global 3.12.0

Verify that the new version of Python is set as the global version:

python --version

Congratulations! You have successfully installed Python. Thanks for using this tutorial to install the latest version of Python programming languages on the Linux Mint system. For additional help or useful information, we recommend you check the official Python website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button