1

I understand Python is used by the OS, and that's why here on Ask Different there are several Q/A about the subject, where answerers tell people to install Python 3.x and leave Python 2.x (used by the OS) alone. That's not an issue because one can have two major versions installed at the same time.

However, my mac (Monterey) came with Python 3.6. What happens if I try to upgrade it to 3.11 (current version at the time of writing), is that going to hurt the OS somehow? If Python uses semantic versioning, logic tells us it shouldn't make any harm, since the major version number is the same, is that correct?

2
  • Funnily enough, several sites (I googled the issue before asking here, of course) claim that Monterey 12.6 comes without Python 2 and without Python 3. That's very strange, my computer is new and I didn't install any Python on it, apparently it really came with Python 3 (ver 3.6) pre-installed. Maybe another program installed Python 3? Maybe a burglar came during the small hours and installed it? Dec 1, 2022 at 7:01
  • I assume that Python 3.6 and Python 3.11 are fairly compatible. e.g. 3.11 calls are compatible with 3.6. Also you could explicitly call the needed version via pathing or aliasing or symbolic link .
    – David Fass
    Dec 5, 2022 at 20:38

2 Answers 2

4

Monterey includes a 'stub' for python 3.6. If you try to use it, the OS will invite you to download the Xcode Command Line Utilities, which includes the full install.

Xcode CLU contains a lot of other stuff that you might not want, so I'd recommend downloading python 3.11 from https://www.python.org/downloads/ and installing it.

The downloaded python is in /usr/local/bin; the system python is in /usr/bin.

As long as /usr/local/bin comes first in your $PATH, then the downloaded python will take priority, and calling python3 will launch the 3.11 version. That's what I do.

I don't think that macOS 'uses' python at all anymore.

4
  • I did install Xcode (for an unrelated task), so that explains why I have a functioning Python 3. So that's even better, if all Monterey has is a "stub" I can safely upgrade Python to 3.11. Just an issue: in terminal if I write type python3 it says /usr/bin, not /usr/local/bin... is that a problem? Dec 1, 2022 at 8:55
  • @GerardoFurtado What does which python3 say? If there's a problem, you'll need to check the order of folders in your $PATH.
    – benwiggy
    Dec 1, 2022 at 9:56
  • it says the same, /usr/bin/python3. Everything is working, I'm just puzzled because it should be local, but it's not. Dec 1, 2022 at 12:27
  • 1
    @GerardoFurtado So is /usr/local/bin in $PATH, before /usr/bin ? What do you mean "everything is working"? Presumably, python3 calls 3.6, not 3.11.
    – benwiggy
    Dec 1, 2022 at 14:20
0

I would make sure to install it in a different path e.g. /usr/local/bin and set the $Path order to use /usr/local/bin first

Or I would be sure to explicitly call the /usr/local/bin/python3 binary if I wanted to use Python 3.11

Or I would create an alias to it in your .profile

Or I would make a symbolic link

ln -s python3.11 /usr/local/bin/python3

Either way, you could make sure that the 2 pythons were separated into different paths... I would hope that Apple's scripts would explicitly call /usr/bin/python3 so there wouldn't be an issue of using the 'wrong' version.

However, I would hope that 3.11 would run scripts in 3.6 formats without issues.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .