Getting Python running on Linux Mint takes less than five minutes once you know the exact commands to use. Linux Mint includes Python in its standard repositories, but managing multiple versions or setting up isolated project environments requires specific tools to avoid breaking system packages.
Python powers everything from simple automation scripts to heavy machine learning models. Linux Mint provides a stable, Debian- and Ubuntu-based foundation that makes local development reliable and straightforward. This guide covers checking your current setup, installing the correct packages, configuring virtual environments, and resolving common path issues without fluff.
Checking Your Current Python Version
Before running any installation commands, check what Python versions already exist on your system. Linux Mint often ships with Python pre-installed for system utilities. Open your terminal by pressing Ctrl+Alt+T and run the standard version check.
python3 --version
If Python 3 is installed, the terminal returns a version number such as Python 3.10 or newer. You can also check if the package manager recognizes the default python command by typing python --version, though modern Linux distributions often leave this unmapped to prevent legacy scripts from breaking system tools.
For official documentation on release schedules and features, consult the Python Software Foundation.
Updating Package Lists
Always refresh your local package index before installing new software on Linux Mint. This ensures your system pulls the most secure and up-to-date packages from the official repositories. Run the update command alongside the upgrade flag to synchronize your package database.
sudo apt update && sudo apt upgrade -y
This step prevents missing dependency errors during installation. It takes a few moments depending on your network speed and how recently you updated the system.
Installing Python on Linux Mint
Linux Mint relies on Advanced Packaging Tool (APT) for software management. To install the default stable version of Python 3, execute the installation command in your terminal.
sudo apt install python3 -y
This command installs the core interpreter, standard library modules, and basic configuration files. Once the process finishes, verify the installation by checking the version number again.
Installing Additional Developer Tools
A standard Python installation lacks the package management utilities required for most development work. You need pip, the standard package installer for Python, along with development headers that allow you to compile C extensions.
Install pip and the virtual environment module by running:
sudo apt install python3-pip python3-venv -y
Using python3-venv is crucial. It lets you create isolated local environments for different projects so that package versions don't conflict across your system.
Setting Up Virtual Environments
Never install third-party Python packages globally into your system environment. Global installations can overwrite packages required by Linux Mint system tools, leading to broken desktop utilities. Virtual environments solve this by creating a self-contained directory containing a copy of the Python interpreter and its own site-packages folder.
Navigate to your project directory in the terminal and create a virtual environment named venv.
python3 -m venv venv
This command creates a folder called venv in your current directory. To start using the virtual environment, you must activate it.
source venv/bin/activate
Your terminal prompt changes to show the name of the active environment in parentheses, such as (venv) user@linuxmint:~$. While active, any package you install using pip stays localized inside this folder. To exit the virtual environment and return to the global system prompt, simply type:
deactivate
For broader Linux ecosystem context and package guidelines, refer to the Ubuntu Documentation since Mint shares its core software repositories with Ubuntu.
Writing and Running Your First Script
Test your new setup by creating a simple Python script. Open a text editor like Nano or Xed and create a file named hello.py.
nano hello.py
Add a basic script that prints a greeting and checks the current Python execution path:
import sys
print("Hello from Python on Linux Mint!")
print("Active Python executable:", sys.executable)
Save the file and exit the editor. Run the script from your terminal using the Python 3 interpreter:
python3 hello.py
The output confirms that the script executes successfully and displays the exact path of the interpreter running it.
Common Installation Mistakes and Troubleshooting
Developers setting up Python on Linux Mint occasionally run into specific roadblocks. Knowing how to fix them saves time.
Broken Pip or Missing Modules
If pip throws errors or claims it cannot connect to the package index, ensure your system time is accurate and your network connection is stable. If pip is missing entirely, reinstall it via apt rather than downloading installation scripts from unverified web sources.
Permission Denied Errors
If you see a permission error while running pip install, you are likely trying to install a package globally without root privileges. Do not use sudo pip install. Instead, activate your virtual environment first, then run pip install package_name normally.
Multiple Python Versions
If you compile custom Python versions from source alongside the system package, paths can become tangled. Use absolute paths to your preferred interpreter or manage versions explicitly using virtual environments to keep your workspace clean.
Frequently Asked Questions
Can I install multiple Python versions on Linux Mint?
Yes. You can install specific version packages from PPAs or compile them from source, though the default repository version is sufficient for most standard development tasks.
Is python3 command required instead of python?
Yes. Linux Mint maps python3 to the Python 3 interpreter. Typing python directly may return an error unless you explicitly configure symlinks or use a virtual environment.
Where should I store my Python projects?
Store your projects within your user home directory, such as ~/Projects/, rather than system directories, to avoid permission issues and simplify file management.
How do I uninstall Python packages?
Inside an active virtual environment, remove any installed package by running pip uninstall package_name and confirming the prompt.