4 Ways to Install Python on MacOS [A Complete Guide]

Reading time: 5 min read
Raj Vardhman
Written by
Raj Vardhman

Updated · Dec 28, 2023

Raj Vardhman
Chief Strategist, Techjury | Project Engineer, WP-Stack | Joined January 2023 | Twitter LinkedIn
Raj Vardhman

Raj Vardhman is a tech expert and the Chief Tech Strategist at TechJury.net, where he leads the rese... | See full bio

Lorie Tonogbanua
Edited by
Lorie Tonogbanua

Editor

Lorie Tonogbanua
Joined June 2023 | LinkedIn
Lorie Tonogbanua

Lorie is an English Language and Literature graduate passionate about writing, research, and learnin... | See full bio

Techjury is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission. Learn more.

Python is one of the most widely embraced programming languages due to its simplicity, versatility, and extensive library support. It claimed the second spot as the most-used programming language on GitHub in 2022. The language's popularity has experienced a consistent upward trajectory in recent years. 

Peter Norvig, the Engineering Director at Google, affirms Python's enduring significance:

"Python has been an important part of Google since the beginning and remains as the system grows and evolves. Today, dozens of Google engineers use Python, and we're looking for more people with skills in the language."

macOS is renowned for being one of the easiest platforms to install Python. Continue reading to discover four simple methods to install Python on your Mac device to start your Python projects.

How to Install Python on Mac?

Installing Python on your Mac is a straightforward process. Also,  Python for macOS supports various Integrated Development Environments (IDEs) and text editors, making programming Python easy.

Macs come with Python pre-installed, so you don't have to worry about installing it manually. However, the pre-installed versions may differ. Python 2.7 is pre-installed on older macOS, while newer ones come with pre-installed Python 3.x. 

If you need to install a newer version or do not have Python, the next section will introduce four other ways to install it on your Mac.

Method 1: Download Python on Mac With Homebrew

Homebrew is a popular open-source package manager for macOS. It makes software installation on Mac devices a lot easier. Developers prefer using it due to its ease of use and efficiency.

Here’s how you can download and install Python on your Mac using Homebrew:

Step 1:  Install Homebrew.

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

Step 2: Check if the Homebrew is installed correctly by typing:

brew doctor

Step 3:  With Homebrew in place, you can install Python

brew install python

Step 4: Ensure that Python is installed successfully by checking the version with this command:

python3   - -version 

Method 2: Use the Command Line Developer Tool

Command Line Developer Tools are tools used by software developers to run commands. With Homebrew, you can easily install Python using the Xcode Command Line Tools. Here’s how: 

Step 1: Install Homebrew on your Mac by entering this command in the Terminal:

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

Step 2: Confirm that Homebrew is installed correctly by running:

brew doctor

Step 3: Check if Xcode Command Line Tools are installed. You can confirm by running:

xcode-select  -p

If it returns a valid path, you will know if the Xcode Command Line Tools are already installed on your device. For example, you will see a result like this: “/Library/Developer/CommandLineTools

If you get an error, install Xcode Command Line Tools by running: 

xcode-select  -- install

Step 4: Install Python 3 using Homebrew with this command:

brew install python

Step 5: To confirm that Python 3 is installed, check its version by typing:

python3 - -version

✅ Pro Tip

Consider using virtual environments like 'conda' to manage Python environments for various projects. This will help you avoid conflicts between dependencies.

Method 3: Install Python on Mac Using Package Installer

The best way to install Python on a Mac is to use the package installer. It is simple and user-friendly. Here is a step-by-step guide on how you can do it:

Step 1: Download the latest Python Installer for Mac from the official Python website.

Python homepage

Step 2: Open the package installer file (.pkg) after downloading. 

Python file on Downloads

Step 3: Follow the instructions provided by the installation wizard to complete the Python installation.

Step 4:  To verify that Python is installed correctly, open Terminal and type:

python3 --version

The output should display the version number of the Python that you’ve just installed.

Method 4: Use Anaconda Distribution to Install Python

Anaconda is a versatile platform for data scientists, researchers, and developers who want to use Python. It simplifies the management of software packages and the setup of environments, making it a good choice for Python development.

Follow the steps below to install Python on a Mac using Anaconda: 

Step 1: Download the Anaconda distribution installer for macOS from the official website.

Anaconda homepage

Step 2: Once the download is complete, open the installer. Follow the instructions to install Anaconda.

Step 3: After installing the Anaconda Navigator, launch it. You can easily find it by searching for “Anaconda Navigator” in the Launchpad or Finder.

Step 4: With Anaconda, you can launch Jupyter Notebook or Spyder, popular Python Integrated Development Environments. 

Jupyter on Anaconda 

How to Uninstall Python on Mac? 

Removing Python on Mac is not recommended since it is required for some applications or scripts in your system. However, if you need to uninstall Python from your Mac, follow these steps:

Step 1: Open the Terminal. You can find it easily by using Finder. 

Terminal on Finder

Step 2: Type the following command and press Enter: 

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

📝 Note

If you have a different Python version, replace `3.9` according to the command with the version that you have.

Step 3: When prompted, provide your admin password and press Enter.

Step 4: Input the commands below in the Terminal. Press Enter to remove Python’s executable files:

sudo rm -rf /usr/local/bin/python3

sudo rm -rf /usr/local/bin/python

sudo rm -rf /usr/local/bin/pip3

sudo rm -rf /usr/local/bin/pip

Step 5: Refresh the system’s command cache:

hash -r

Conclusion

Python's widespread popularity and versatility make it an invaluable tool for developers. When installing Python on your Mac, whether using the pre-installed version or opting for a more customized setup, Python grants you access to many coding possibilities.

You can select from various installation options. However, remember that while knowing is essential, exercising caution during uninstalling is equally vital.

FAQs.


Do you need XCode to install Python on a Mac?

You do not need Xcode to install Python on your Mac. You can install Python using methods like Homebrew, a package manager, or downloading it directly from the official website. 

What version of Excel supports Python?

The version of Excel that supports Python is Excel 365.

Is Python on Mac the same as Python on Windows?

Yes, Python is the same programming language on Mac and Windows. There are differences in how you manage and install Python on these systems, but it works the same way.

SHARE:

Facebook LinkedIn Twitter
Leave your comment

Your email address will not be published.