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

26 comments sorted by

14

u/SilentBlueberry2 12h 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 8h ago

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

2

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

1

u/Geoff12889 2h ago

Thanks, I'll check these out. Using venv should beat using Anaconda, I'd assume.

2

u/fiddle_n 1h ago

If you are using PyPI-only dependencies, then yes I would start with pip+venv, and then when familiar with that, consider uv.

-3

u/silverknife42 12h ago

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

why not?

5

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

2

u/teetaps 8h 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

13

u/Classic_Mammoth_9379 12h ago edited 12h 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”. 

1

u/Timely-Bend2056 9h 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

1

u/xenomachina xenomachina 8h ago

Old patch versions get cleaned up automatically after brew upgrade (via brew cleanup). New minor versions are separate formulae (python@3.12, python@3.13), so they're kept side by side, since minor versions aren't binary-compatible and other formulae may depend on a specific one. brew autoremove removes old versions that were not manually requested and that no installed homebrew packages depend on. For manually requested old versions you need to brew uninstall python@3.x.

Either way, this breaks any venvs built on that version. (Another reason to use uv and have it manage its Python installs, imho.)

-5

u/silverknife42 12h ago

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

2

u/Classic_Mammoth_9379 11h ago edited 11h 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?

1

u/xenomachina xenomachina 8h 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.

9

u/ninhaomah 12h ago

uv

2

u/xeow 9h 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/pythonwiz 9h 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.

5

u/Mad-riffer 12h 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 11h 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 11h 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!

1

u/VintageKofta 2h ago

Honestly. The easiest way I found to maintain and update it is via Homebrew. Same with many other apps too. 

1

u/LegalDebate5423 1h ago

If you want to keep the [python.org](http://python.org) install, use its installer for the version you want and leave macOS's own Python alone. For project work, a version manager like `uv` can install Python versions and create isolated environments, so you don't need to replace a system-managed interpreter. Check which executable `which python3` resolves to before removing anything.

•

u/gernophil 4m ago

macOS doesn’t come with a system Python. You are probably using the one from Xcode. Don’t use that outside of Xcode.

I prefer using Python from python.org, but there are other options (brew, conda, uv…). Use one of those. They are pretty easy to update.

0

u/avidresolver 12h 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 12h 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.