Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstalling python3 on MacOs

I have uninstalled python3 using brew on macOS Catalina 10.15.3:

brew uninstall python3

brew list | grep python
python@2

But it still there:

which python3
/usr/bin/python3

python3 -V
Python 3.7.3

/usr/bin/python3 -V
Python 3.7.3

ls -ltah /usr/bin/ | grep python

-rwxr-xr-x     1 root   wheel    31K Jan 23 16:58 python3
lrwxr-xr-x     1 root   wheel    75B Dec 16 06:20 python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x     1 root   wheel    82B Dec 16 06:20 python-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x     1 root   wheel    76B Dec 16 06:20 pythonw2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x     1 root   wheel    82B Dec 16 06:20 python2.7-config -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7-config
lrwxr-xr-x     1 root   wheel    76B Dec 16 06:20 pythonw -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7
lrwxr-xr-x     1 root   wheel    75B Dec 16 06:20 python2 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
lrwxr-xr-x     1 root   wheel    75B Dec 16 06:20 python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

It's interesting but on error it shows different location of python:

python3 -bla

Unknown option: -l
usage: /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python [option] ... [-c cmd | -m mod | file | -] [arg] ...
Try `python -h' for more information.

Seems it's related to Xcode.

How to delete this version python3 and reinstall python using brew?

Update:

sudo rm -f /usr/bin/python3
rm: /usr/bin/python3: Operation not permitted
like image 887
mrgloom Avatar asked Feb 18 '20 11:02

mrgloom


1 Answers

Catalina comes with python3 installed by default**. You can't delete it, because /usr/bin is on the System's read-only volume.

If you install your new python to a bin folder that comes before /usr/bin in your $PATH, then it should take precedence.

** (Well OK, the first time you run it, you have to install Xcode command line tools to make it work. But that file itself is a system install.)

like image 143
benwiggy Avatar answered Nov 15 '22 08:11

benwiggy