How to Uninstall Python on macOS

Lakshay Kapoor Feb 02, 2024
  1. Use the Command-Line of macOS to Uninstall Python on macOS
  2. Remove the Symbolic Links to Uninstall Python
How to Uninstall Python on macOS

Every software in the world has to be updated from time to time to make the most efficient use of that software. There are many bugs in every software that needs fixing. Some many libraries and packages are not present in the older Python version. So, at times, the user needs to delete the older version and download the latest one to use the new packages and libraries.

This tutorial will introduce some methods to uninstall the older version of Python, i.e., Python 3.9 on macOS.

Use the Command-Line of macOS to Uninstall Python on macOS

Just like Windows OS has Command Prompt, macOS has its command line called the Terminal.

To remove all the Python Frameworks in the working directory, run the following command in the terminal.

sudo rm -rf /Library/Frameworks/Python.framework

After pressing enter, you may need to enter your system’s password to run the command.

Now, remove Python 3.9 from the macOS.

~ sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.9

Homebrew on Mac is a free of cost open-source software management system that helps manipulate macOS software like installing and uninstalling software. Homebrew is also used in Linux.

To install Homebrew on Mac, run the following command in the Terminal.

*/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

This software basically finds the symbolic links of Python and removes them. To find the symbolic links, run the following command:

 ~ brew doctor

After running this command, a list of Python symbolic links will appear on Terminal, with a command brew cleanup to remove those links. Type that command on the Terminal and press enter to remove those links.

Symbolic links which refer to the Python Frameworks are stored in /usr/local/bin directory.

To view these links, run the following command.

ls -l /usr/local/bin | grep '..Current/Library/Of/Frameworks/Python.framework'

In the above command, the path is mentioned in between ' '. This command will return all the links for the Python Framework.

To remove these links manually, first, enter into a directory by using the following command:

cd /usr/local/bin

To delete the Symbolic links in the directory, run the following command.

ls -l /usr/local/bin | grep '..Current/Library/Of/Frameworks/Python.framework' | awk '{print $9}' | tr -d @ | xargs rm

NOTE: The path should be mentioned by the user itself, which is mention between ' '.

Lakshay Kapoor avatar Lakshay Kapoor avatar

Lakshay Kapoor is a final year B.Tech Computer Science student at Amity University Noida. He is familiar with programming languages and their real-world applications (Python/R/C++). Deeply interested in the area of Data Sciences and Machine Learning.

LinkedIn

Related Article - Python Uninstall