Delete /usr/bin/python3 on mac

Viewed 2973

I am trying to remove all my python for reinstall them properly. I have check lot of stack overflow topic, and now I am at this point :

when I am doing

which python3

I have :

/usr/bin/python3

also, doing

ls -l /usr/bin/python*

give :

lrwxr-xr-x  1 root  wheel     75  4 avr  2020 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x  1 root  wheel     82  4 avr  2020 /usr/bin/python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x  1 root  wheel     75  4 avr  2020 /usr/bin/python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x  1 root  wheel     75  4 avr  2020 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x  1 root  wheel     82  4 avr  2020 /usr/bin/python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
-rwxr-xr-x  1 root  wheel  31488 10 jul 00:26 /usr/bin/python3
lrwxr-xr-x  1 root  wheel     76  4 avr  2020 /usr/bin/pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x  1 root  wheel     76  4 avr  2020 /usr/bin/pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7

so clearly my last python3 to remove is : /usr/bin/python3

but when I am doing :

rm python3

I have the question :

override rwxr-xr-x  root/wheel restricted,compressed for python3? y       
rm: python3: Operation not permitted

and here I am completely block, what is the next step ?

I am doing that because that point on a python3.8 (install by brew) and what I want is a python3.7 so if you have a better solution than delete this version to reinstalle 3.7 I am also open to a solution, I am stuck with this issue

thanks

2 Answers

A followup on this post from 2022. I meet the same problem today. I did my research on the Internet and experimented all of those on my own. Unfortunately, none succeeds. All I can do now is to summarize those for the latecomers, and please let me know if a good solution comes up.


First I tried is the sudo method. Which gives the same "Operation not permitted" error. Which is weird. Some posts accuse the system as I am also using MacOS. I am not sure if that is also the case of kilag. Anyway, as a response from ls -ld /usr/bin, we can see the operation should be allowed:

drwxr-xr-x  1012 root  wheel  32384  9 May 14:30 /usr/bin

There is also a post mentioning flags which can be revealed by ls -lO. Their programs are successfully deleted after changing the flags by chflags. However, as ls -lO gives restricted, compressed flag for python3 directory which is not even defined in chflags. I pause there.

sudo rm /usr/bin/python3

or

sudo rm -r usr/bin/python3
Related