We all have been there trying to figure out the root cause of failure of your scripts, we finally decide to get ride of python once and for all (not really ;))
This is my opinionated post on how to clean python completely from your system and then do a fresh install
Use Homebrew to do the heavy lifting
check to see if homebrew
is installed on your system. more info on its website -> https://brew.sh/
$ brew --version
Homebrew 2.5.11
Homebrew/homebrew-core (git revision d4069; last commit 2020-11-18)
Homebrew/homebrew-cask (git revision 0374c82; last commit 2020-11-18)
If you don't see the above, lets install homebrew
.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Now you should be able to run
$ brew --version
Clean up existing Python installations
Note please dont remove the existing python 2.7 which comes along with your mac, there might be apps using this !
so the default installation of python exists at /usr/bin/python
, lets keep it as is
However, the python installations located in /usr/local/bin
are often symbolic links and can be deleted.
List all those by running
$ ls -l /usr/local/bin/ | grep python*
You should now see a list of links which are most likely installed in this path -> ../../../Library/Frameworks/Python.framework
. If Python were to be installed by Homebrew
, it would be installed in the path -> /Cellar/python@...
Clean up all python links
$ sudo rm /usr/local/bin/python*
$ sudo rm /usr/local/bin/pip*
$ sudo rm /usr/local/bin/easy*
Remove versions of python install in the Framework path
$ sudo rm -Rf /Library/Frameworks/Python.framework/Versions/*
Environment setup
open ~/.bashrc
and ~/.bash_profile
and clean up all the references to python Framework path and only have
export PATH='/usr/local/bin:/usr/local/sbin:/usr/bin:$PATH'
Install Python using brew
Using brew install python
$ brew install python3
Note: as of Nov 17, 2020: the above command will install python@3.9
To always keep the python updated using brew
$ brew upgrade
Hope this helps keep a clean and updated python version
🍻
Top comments (1)
Isn't it risky to wipe out the system python interpretator? I used pyenv to manage multiple python versions on Mac and I'm happy with it