Python Update Linux [top] 📍

python3.12 -m pip install --upgrade pip Create a virtual environment with the new version:

python3.12 my_script.py Or use update-alternatives (Debian/Ubuntu): python update linux

sudo dnf upgrade python3 – default repos are outdated. Use EPEL or source compilation. python3

which python3 ls -l /usr/bin/python* Most stable method. It updates Python only to the latest version provided by your distribution’s official repositories – not the absolute latest upstream release. Debian / Ubuntu / Linux Mint sudo apt update sudo apt upgrade python3 To see available Python versions: It updates Python only to the latest version

python3.12 --version Version managers let you install multiple Python versions per user without sudo . pyenv (Most popular) # Install pyenv curl https://pyenv.run | bash Add to ~/.bashrc echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc source ~/.bashrc Install a new Python version pyenv install 3.12.2 pyenv global 3.12.2 # set as default for your user conda / miniconda Great for data science and isolated environments.

apt list -a python3 If you need a newer version than the repo provides, use a (Ubuntu) or deadsnakes :

sudo rm -rf /usr/bin/python3 sudo ln -s /usr/local/bin/python3.12 /usr/bin/python3 This breaks apt , gnome-terminal , software-properties-gtk , and many other system tools. Check all installed Python versions: