r/learnpython • • 10h ago

updating Python on macOS

How do you update Python on macOS? I looked it up and from what I can tell, there is no simple command you can enter into the terminal to update it, and you have to instead go to the website https://www.python.org/downloads/ and download and install it manually to update which is inconvenient. There's also the question of removing the old versions you have no intention of using anymore.

I am aware of Homebrew and I do have it for other things I've installed, but I want to try to only use it to download things to my MacBook that I otherwise couldn't. Python can easily be downloaded for mac separately and I want to keep it that way if possible. Is there no update command for the mac terminal to simply update Python?

11 Upvotes

22 comments sorted by

View all comments

14

u/SilentBlueberry2 10h ago

Use a package manager for python with virtual environments, otherwise youre updating the system python, which almost certainly is not what you want to do. Use uv or virtualenvs or conda or pixi, depending on what you need to install.

1

u/Geoff12889 6h ago

Any suggestions on a crash course to learn about virtual environments? Preferably whatever is built into vanilla Python.

1

u/fiddle_n 1h ago

This blog article by Niels Cauterts named “Python Dependency Management is a dumpster fire” is one of the best articles I saw posted on here that really explains the problem at hand and what tools like venv and others (conda, uv, etc) are trying to solve.

As for actually using venv, there’s only three commands you need to learn - how to create a virtual environment, how to activate a virtual environment and how to described it. Commands are slightly different depending on your OS and shell, so I would suggest just reading https://docs.python.org/3/library/venv.html to understand how to use them.

-3

u/silverknife42 9h ago

otherwise youre updating the system python, which almost certainly is not what you want to do

why not?

5

u/Temporary_Pie2733 9h ago

Theoretically, the system-installed Python is primarily for and tracked by the OS itself, and should not be updated except by official OS updates. You can use it in a read-only capacity, but don’t modify it outside official channels, as theoretically there might be system scripts that depend on the officially installed version. 

1

u/teetaps 5h ago

Because it’s a system library. The whole system kinda expects that it is gonna be there in the way that it was for the OS. It’s not gonna instantly break your OS if you change it, but you do risk a lot of things you can’t predict, breaking because they relied on it.

But a more convincing argument might be this: virtual environments are dirt cheap. That’s why there are so many environment managers. Just pick one and roll with it, it costs you very little and benefits you by preventing you from breaking something you shouldn’t