terminal – How to create a link to python3 on MacOS?

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.

Author: Subham

Leave a Reply

Your email address will not be published. Required fields are marked *