How To Update Python ^hot^ <PREMIUM · GUIDE>

Here is exactly how to update Python on Windows, macOS, and Linux without pulling your hair out. Do not just update your system Python and hope for the best. If you do, libraries installed via pip for your old version might vanish, and legacy scripts will crash.

export PATH="/usr/local/opt/python/libexec/bin:$PATH" WARNING: Never uninstall the default python3 package on Linux. The OS uses it for critical tools (like apt ). You will crash your system. how to update python

Let me know in the comments below if you hit any snags Here is exactly how to update Python on

Use Virtual Environments. Always. (We will cover fixing your global Python first, then how to protect your projects). How to Update Python on Windows Windows does not come with Python pre-installed, so you likely installed it via the executable. Updating is straightforward. Step 1: Check your current version Open Command Prompt (cmd) or PowerShell and type: Let me know in the comments below if

python --version Windows allows side-by-side versions. To run the old version later, use py -3.9 instead of python . How to Update Python on macOS MacOS ships with an ancient, system-dependent version of Python 2.7 (or 3.6 on older OSes). Do not touch the system Python. Instead, use Homebrew. Step 1: Install Homebrew (if you haven't) Open Terminal and paste:

# Install dependencies sudo apt update; sudo apt install 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 curl https://pyenv.run | bash Add to your ~/.bashrc (or ~/.zshrc) echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc source ~/.bashrc Install and set the new version pyenv install 3.12.0 pyenv global 3.12.0 Verify python3.12 --version The "Uh-Oh" Moment: How to fix pip after an update You updated Python, but now when you run pip install requests , you get errors.

If you have ever tried to run python3 --version only to sigh because you are still stuck on Python 3.8, this guide is for you.