My Mac has Python3 and 2.7 installed. How do I uninstall Python3 but keep 2.7?

rmtree verb is not available in the default install of Homebrew.

MacBook-Pro:~ admin$ brew rmtree python3
Error: Unknown command: rmtree

You can use uninstall verb as:

MacBook-Pro:~ admin$ brew uninstall python3
Uninstalling /usr/local/Cellar/python/3.6.5... (5,102 files, 102.9MB)
MacBook-Pro:~ admin$ python3
-bash: python3: command not found
MacBook-Pro:~ admin$ python
Python 2.7.10 (default, Oct  6 2017, 22:29:07) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

However, rmtree can be installed by executing the following:

$ brew tap beeftornado/rmtree
$ brew rmtree <package>

Using rmtree, one can cleanly and completely remove a package installed from Homebrew, along with all of its dependencies.


It depends on how you installed python3.

If you installed python3 via the official mac installer(.dmg), you need to remove it from Finder -> applications. Just drag the python3.x icon to the Trash icon on the bottom right corner. If you had installed several versions of python3, you may find more than one python3.x icons, each one corresponds to a single python3 version instance, you may choose which one to remove.

If you installed python3 via a package manager like brew, you need to use the remove command from the package manager, for example, brew uninstall python3.


You may have multiple versions of Python 3.x installed on your Mac. To uninstall all of them, first check which are installed:

brew list | grep python

Let's say you have 3.9 and 3.7 installed. To remove 3.9, run this command:

brew uninstall [email protected]

To remove 3.7, just replace 3.9 with 3.7 above.


If you used homebrew to install python3 the command to remove it is

brew rmtree python3

You should be able to have both versions installed. Call your scripts via

 python myScript.py

This will use your python2.7. If you want to use python3 the command would be

python3 myScript.py

Try

pyenv:

To get all installed versions:

pyenv versions 

To get uninstall specific version

pyenv uninstall 3.5.0

Similarly to install specific version

pyenv install 2.7.10