[Updated] Remove /usr/bin/python3 or not?

KC Analytics
2 min readSep 6, 2020

--

Note: macOS Catalina includes Python3 by default. The most recent version is 3.7.3!

$ xcrun python3
Python 3.7.3 (default, Mar 6 2020, 22:34:30)
[Clang 11.0.3 (clang-1103.0.32.29)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

Since it’s a default version, you can reconsider whether or not you’d still want to remove it. If so, please keep reading.

My Plan

  • keep all default Python (2x and3x)
  • install a Python3 via Pyenv

I made many mistakes while downloading Python from Anaconda, Python Installer, Homebrew and so on. Hence, there are many files and directories left in my system. I figured that I could find the trace of those through bash_profile, which contains all the startup configuration and preferences for your command-line interface. [5]

open ~/.bash_profile

Check the total directories of installed Python3x at your terminal.

which -a python3

For example, I installed Python3 via Homebrew. Somehow, when I open JupyterLab, it shows 3 versions of Python3, which all works. Now, I wanna minimise the amount of installed python.

rm -rf /usr/bin/python3 
rm: /usr/bin/python3: Operation not permitted

After failed many times, I now have to disable SIP. In the end, I finally removed my python3 under /usr/bin/ directory. Don’t remove all of your default Python. Keep at least one. [6]

Steps:

  1. Boot to Recovery OS by restarting your machine and holding down the Command-R keys at startup.
  2. Launch Terminal from the Utilities menu.
  3. Enter the following command
$ csrutil status
System Integrity Protection status: enabled.
$ csrutil disable

4. After enabling or disabling System Integrity Protection on a machine, a reboot is required.

5. Enter the following command

sudo chown $(whoami):admin /usr/bin/
rm /usr/bin/python3

Terminal would ask

override rwxr-xr-x  root/wheel restricted,compressed for /usr/bin/python3?

Type either ‘y’ or ‘yes’. Then, check whether your python3 is removed.

ls /usr/bin/
which -a python3

6. Repeat step 1–4 except step 2 to enable SIP in order to protect your laptop from.

$ csrutil enable

You shall not find python3 anymore. Don't remove all default Python (2x and 3x), which will cause problems to your MacBook. Now, you're ready to install your own versions of Python at your wish. [3]

--

--