Multiple Versions of Python
How to remove multiple versions of python from macOS

In my machine, when I worked on my previous project I installed unhesitantly more than one version of python these were python 2.6, 2.7, 3.6, 3.8, and 3.9.
2.7.16 and 3.8.2 were default versions provided on mac and the rest were from https://www.python.org, anaconda, and home-brew.
When I begin a new project, start facing issues with package installation and managing these versions. Googled to uninstall third parties versions, leaving the default ones so that I can work in a more clean environment.
Solutions that did not worked:
- Deleted python folders manually from root.
- Removed python PATHS from .bash_profile.
- Tried https://stackoverflow.com/a/3819829.
- brew uninstall — ignore-dependencies python3(It worked to uninstall python 3.9 only).
- Linking and unlinking to specific versions.
But things get messier than before.
In the way, I start facing an error with which PIP.
[root@bkd-openam ~]# pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/9e/24/bc928987f35dd0167f21b13a1777c21b9c5917c9894cff93f1c1a6cb8f3b/pip-21.0.tar.gz
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Running setup.py install for pip ... done
Successfully installed pip-21.0
[root@bkd-openam ~]# /usr/bin/pip2 install --upgrade pip setuptools pyOpenSSL psycopg2-binary lxml
Traceback (most recent call last):
File "/usr/bin/pip2", line 9, in <module>
load_entry_point('pip==21.0', 'console_scripts', 'pip2')()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
Later my python broke, trying different solutions to fix it did not work, some say upgrade pip but no luck.
pip install - -upgrade “pip < 21.0”
It was not letting me work with my current project by throwing errors. By trying available solutions, these versions still present and interfered from somewhere and had no luck to clean.
So a solution came up in my mind and I had to take this hard decision.

Reset mac machine.
For mac reset:
- Press power button.
- Right after pressing power button, hold-down Command and R keys, until you see apple logo.
- Then you will get into mac recovery mode. From there click disk utility.

4. Click Macintosh HD, then erase. Change name whatever you want and format into Mac OS Extended (Journaled).

5. Now close disk utility form menu bar.
6. Initial window will appear again, there you have an option of reinstall macOS click it and contine.

8. Select disk where you want to install and continue.

7. After macOS installation, your macbook is factory reset.
Before resetting back up your data, and you can do it by:
- Using Time Machine.
- Using iCloud.
- Using external storage device(USB, SSD Card etc).
Ciao and enjoy problem solving!