Linux 2021: Upgrade Python
conda install python=3.12 # Or create a new environment conda create -n py312 python=3.12 conda activate py312 After upgrading, ensure pip is updated for the new Python version:
Instead, install new Python versions alongside the system Python. Method 1: Using the Official Python Installer (Recommended) This method works on almost any Linux distribution and installs Python to /usr/local/bin , leaving the system Python untouched. Step 1: Install Dependencies # Debian/Ubuntu sudo apt update sudo apt install -y build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev curl \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev Fedora/RHEL/CentOS sudo dnf groupinstall -y "Development Tools" sudo dnf install -y openssl-devel bzip2-devel libffi-devel readline-devel sqlite-devel Step 2: Download Python Visit python.org/downloads or use wget to get the latest version (replace 3.12.2 with the latest version): upgrade python linux
python3.12 -m pip install --upgrade pip To install packages for your new Python: conda install python=3
pyenv – it's safe, flexible, and doesn't require root. Upgrading Python on Linux can be approached in
Upgrading Python on Linux can be approached in several ways, depending on your Linux distribution, whether you want to replace the system Python, and your need for multiple Python versions. This guide covers the safest and most common methods. Important Warning: Don't Replace the System Python Most modern Linux distributions (Ubuntu, Debian, Fedora, CentOS, etc.) rely on their default Python installation for critical system tools like apt , yum , and gnome-terminal .