pyenv automatically manages python and pip to point to your chosen version without touching system Python. Ubuntu / Debian (via deadsnakes PPA) sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt install python3.12 python3.12-venv python3.12-dev Usage: python3.12 Fedora sudo dnf install python3.12 Usage: python3.12 Arch Linux sudo pacman -S python Arch is rolling-release, so python is usually up-to-date. Method 4: Using Conda (Data Science Focus) If you use Anaconda or Miniconda:
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 . upgrade python linux
export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" Restart your shell. # List available Python versions pyenv install --list Install a specific version pyenv install 3.12.2 Set global (user-wide) Python version pyenv global 3.12.2 Set local (project-specific) version pyenv local 3.12.2 Verify python --version pyenv automatically manages python and pip to point