I want to remove python3
from /usr/bin
, as I already have Python 3.11 installed and the python3
in /usr/bin/
is Python 3.9.6
I tried removing it using sudo rm -f python3
, but I get this error:
rm: python3: Operation not permitted
So, how?
You probably should think thrice before attempting this. In your case, you can simply use the python
version in /usr/local/bin
by manipulating the $PATH
variable. Homebrew probably does this automatically, you can try which python
to find out what's the default on your system.
If you really, really want to do this, you can follow the guide here: https://stackoverflow.com/questions/57440334/sip-is-disabled-but-usr-bin-is-write-protected-anyway-macos-catalina-beta-10/59395264#59395264
Modify PATH in ~/.zprofile like so:
export PATH="/usr/local/bin:/opt/local/bin:/opt/local/sbin:$PATH"
Open a new Terminal session.
Most tools, like Visual Studio Code, will be able to detect all Python installations and let you choose.
This way you also can handle Python installed in /Library/Framework and Xcode, without going around and deleting.
/usr/bin is handled by the macOS and is protected by SIP (System Integrity Protection), which can be disabled, but why bother.