r/learnpython • • 4h 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?

1 Upvotes

18 comments sorted by

9

u/SilentBlueberry2 4h 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.

•

u/Geoff12889 19m ago

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

-1

u/silverknife42 3h ago

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

why not?

4

u/Temporary_Pie2733 3h 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. 

10

u/Classic_Mammoth_9379 4h ago edited 4h ago

Why are you setting arbitrary constraints for yourself? 

This is easy on most Linux distributions by using a package manager like yum or apt. 

The most popular package manager on macOS is homebrew and you’ve already got it installed. “brew upgrade python”. 

•

u/Timely-Bend2056 49m ago

does brew actually clean up the old python versions automatically when you upgrade, or do you still have to run a cleanup command after

-4

u/silverknife42 3h ago

because i dont like using 3rd party programs or websites to download things. i always try to download from source

1

u/Classic_Mammoth_9379 3h ago edited 3h ago

Surely python.org is a 3rd party to you just in the same way homebrew is? What is it that you don't like about it... given that it gives you the result you want in the fashion you asked for?

•

u/xenomachina xenomachina 6m ago

I think that, by OP's reasoning, OP and python.org are the first and second party, while homebrew is a third party. An (unnecessary?) middle man, in a sense.

That said, I agree with you. If you want a quick command line way to install and update python, homebrew is the de facto solution on macOS.

7

u/ninhaomah 4h ago

uv

•

u/xeow 53m ago

This should be the top answer. 100%. This is, hands-down, the most headache-free way to install multiple versions of Python (or even a single version) cleanly and quickly. Don't use MacPorts; don't use Homebrew; don't download yourself. Use uv. You'll thank yourself later.

3

u/Mad-riffer 3h ago

If you want to be a serious python dev, look up uv or similar tools. Don’t even use the os python.

0

u/Mad-riffer 3h ago

Also, I understand this may be non obvious as to why you want to do this. It is about control. In the professional world you can control package managers. You cannot control requirements (unless you’re the one who starts the project). So being skilled at using a package manager is a must. Because every project can have different requirements. And if you try to accommodate them using the os python…. I haven’t done that in a long time and I don’t want to think about the horrors you might encounter.

2

u/SharkSymphony 3h ago

Nope! The official Python installation on MacOS assumes you'll be installing the same old dirt-simple way Mac users have been installing for aeons: manually download, double-click to install.

Which is why Homebrew comes with cask support, BTW – so that you can install/uninstall Mac apps using its command-line package manager, if that's what floats your boat! Homebrew's no longer just for things you can't install any other way.

But there are plenty of other options for you beyond those two, as outlined in other comments, if you don't like either of those options. Each option has its pros and cons. Pick the one you like the best!

•

u/pythonwiz 36m ago

Homebrew or Macports are the best ways. Or you could write your own script to download and install python then update your symbolic links to point to the new version if you want.

0

u/avidresolver 4h ago

I generally don't like updating python in-place, it's liable to break things. Homebrew also IMHO makes it a little hard to figure out which version of python you're using, because it may install different versions depending on what other packages need. I prefer downloading I specific build and installed it manually and deliberately.

0

u/mumpie 3h ago

install homebrew and following their instructions:

https://docs.brew.sh/Language-Runtimes-and-Packages

I currently have 3 different versions of python installed via homebrew (3.13, 3.14, and 3.15).

I used pyenv to switch between the different versions as needed.

Leave the system python alone as it may be used by other applications.