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, 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:

  1. Deleted python folders manually from root.
  2. Removed python PATHS from .bash_profile.
  3. Tried
  4. brew uninstall — ignore-dependencies python3(It worked to uninstall python 3.9 only).
  5. 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
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Running 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/", line 378, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/", line 2566, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/", line 2260, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/", 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:

  1. Press power button.
  2. Right after pressing power button, hold-down Command and R keys, until you see apple logo.
  3. 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:

  1. Using Time Machine.
  2. Using iCloud.
  3. Using external storage device(USB, SSD Card etc).

Ciao and enjoy problem solving!