1

MacBook Pro outfitted with Ventura 13.2.1

It is my understanding that

  1. "system" python: macOS Catalina or later is deployed with Python3.x
  2. removing system python is fatal / requires OS to be reinstalled

How does one return the version of the system Python?

I think that [email protected] was installed by brew:

brew list | grep -i python   
[email protected]

Though I am not 100% sure. If it is not the system python I'd like to remove it. I'd like to avoid the fatal mistake of removing system python.

How can I be certain that:

brew uninstall [email protected]

will not remove the system python?

gatorback
  • 3,031
  • 8
  • 40
  • 57
  • Hmm - is your problem you want to change the path so any python you installed on top of the system files isn’t run? Not sure why the “removing system python is fatal / requires OS to be reinstalled” statement is provided. Ventura has a sealed system, so you wither messed with that (which is quite tricky and depends on Intel vs Apple Silicon for the process to accomplish it). Are you saying you didn’t tamper with the system? – bmike Dec 30 '23 at 15:04
  • Seeking to remove python versions: I have too many version of Python installed: brew install hidapi fails to import => https://stackoverflow.com/questions/77732954/ – gatorback Dec 30 '23 at 16:26
  • If you install hidapi via brew, you should also install Python via brew. Looks like your problem comes from having two partially conflicting brew versions. – nohillside Dec 30 '23 at 16:35

4 Answers4

15

Homebrew installations are independent of macOS, you can neither update system components via Homebrew nor remove them with brew uninstall.

nohillside
  • 100,768
4

To answer the question in the title: /usr/bin/python3 -V will report the version of the system Python.

If you don't use sudo or other means to give brew root access, it cannot possibly affect any macOS components (including the system Python) unless you have changed their permissions previously, even with very old versions of macOS.

Since OS X El Capitan, there is System Integrity Protection, which means you now cannot change macOS components (including the system Python) even with root permissions, unless you specifically disable SIP first.

See: About System Integrity Protection on your Mac

telcoM
  • 141
  • 1
    As Python is now not installed by Apple unless you install Xcode - Apple's python is not protected by SIP. First two paragraphs are correct. – mmmmmm Dec 31 '23 at 10:27
2

How does one return the version of the system Python?

/usr/bin/python3 -V 

returns:

Python 3.9.6
benwiggy
  • 35,635
0

On my machine with macOS 14.2.1 Sonoma, I found more than one python3. I'm not sure any "came with" Sonoma. First, in a terminal, which python3 returns '/opt/homebrew/bin/python3'. I looked in /usr/bin/ and found a python3 there, too. Using /usr/bin/python3 -h gave me too much info but showed a path indicating it was installed with Xcode. Here's a way to get the version: in a terminal, simply type the name of the python you want examine (this starts the python REPL - use Ctrl-D to exit). It will tell you about itself. I did that for the two pythons I found, and the one from homebrew was Python 3.11.6, and the one in /usr/bin was Python 3.9.6. If you ask homebrew to uninstall python, it will uninstall the one in its directory. Note that, at least on my system, only python3 shows up, not python or python2.

Added: Homebrew will uninstall the Python in the homebrew directory. This is not the system Python. The main point of homebrew is to add (and remove if necessary) software without messing with what the system uses. And as far as I remember, your macOS, Ventura, did not come with a system Python. Is there something else in this picture - such as another installation that depends on Python - that leads to your concern?

More: Thanks to everyone for your followup comments and corrections ;) I think my post and its comments don't need further work. I did give the OP correct information amid reproducing how I found the answers on my system, and by now others have much more succinctly addressed the main points: homebrew won't mess with system stuff; Ventura did NOT come with any "system python"; find the version of python(s) with python3 -V, and location path info with python3 -h.