5

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

kilag
  • 509
  • 1
  • 6
  • 19
  • [This post](https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula) has instructions on how to install specific versions of formulas using homebrew – Lisa Oct 09 '20 at 19:06

3 Answers3

0

Forget about deleting python3 under /usr/bin/python3. Just simply download python again from official website. It will install a package which will automatically save under /Library/Frameworks/Python.framework/Versions/3.10/bin/python3. It simply worked fine for me and I'm not facing any issues.

I was also a new Mac User. I don't remember how I installed python the first time. But it installed under /usr/bin/python3. You can check this by running --> which python3.

I was facing problems using the packages I installed with pip. Pip was installing the packages under the /Library/Frameworks/Python.framework/Versions/3.10/bin/pip3. You can check this again by running which pip.

Thus the clashes.

You may have seen or if you get an error like this -->

Defaulting to user installation because normal site-packages is not writeable

If that's the case, Just download new python!

-1

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.

Klvvrt
  • 1
  • 1
-5
sudo rm /usr/bin/python3

or

sudo rm -r usr/bin/python3
Andronicus
  • 25,419
  • 17
  • 47
  • 88
Metaljerk
  • 11
  • 2