0

Running MacOS 13.1 (Ventura) I see that python3 is installed in /usr/bin, which I can call by running python3. However, I also want to run python3 by just calling python, so I changed to the folder /usr/bin and run the command

sudo ln -s python3 python

which ended in the error

ln: python: Operation not permitted

Maybe I need more than root rights, or what weird Mac thing is going on?

However, what to do to link python to python3?

2
  • /usr/bin/ is part of the read-only system volume. You can't add, delete or modify anything there.
    – benwiggy
    Dec 15, 2022 at 17:22
  • It seems that you can't even create a link from /some/other/directory/python to /usr/bin/python3. Well, you can create a link, but then running /some/other/directory/python fails, at least for me. Dec 15, 2022 at 18:34

1 Answer 1

2

Basically you cannot.

The simplest solution is to create an alias for python. In you ~/.zprofile file add

alias python='/usr/bin/python3'

This means that when you type python you get python3. However you can't run a python script with #! /usr/bin/env python as the first line, which I think is good as you should make that explicitly python3.

However if you are using python heavily then the general opinion is not to use Apple's python but to install it from elsewhere. I would recommend from conda (or pay for anaconda if doing this professionally) or from python.org. Alternatively via a package manager e.g. MacPorts, Homebrew nix.

The reason you cannot change or add things in /usr/bin in modern version of macOS is that Apple puts most of the system onto a separate volume that cannot be written to and to enforce that it also checks that it has not been altered.

You must log in to answer this question.

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