In this tutorial, I will demonstrate how to install python3 on MacOS.
MacOS comes with Python 2 preinstalled, but you will want to install Python 3 to work with the most up-to-date version of Python.
In this post we will cover the 3 main ways to install Python on MacOS
- Install Python With XCode
- Install Python With Package Installer
- Install Python With Homebrew
Check this If you are looking to install Python on Windows instead.
You can also run Python on Google Colab and that doesn’t require any installation.
Check if Python is Installed
$ python --version $ python3 --version
1. Install Python With Command Line Developer Tool
When you type in “
python --version“, you get a message saying:
no developer tools wer found at '/Applications/Xcode.app', requesting install. Choose option in the dialog to download the command line developer tools.
And a prompt like the one below telling you to install Xcode.
Xcode will also install Python 3 on your MacOS, but also a few other softwares in the process (which you may not want).
If you don’t get the pop-up
Install Xcode in the Terminal with the command below:
$ xcode-select --install
2. Install Python with Package Installer
The best place to install Python is from the official website.
Go to Python.org and click on the Download button to download the latest version for MacOS.
Go to your download folder and double-click on the
python-<version>-macosx.pkg file to start the Python installer.
Go through each of the prompts.
Keep the default install location.
Close and move installer to Trash.
3. Install Python with Homebrew
Homebrew is a package installer.
First, install Homebrew.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Then, install brew to Path:
$ export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Next, install Python.
$ brew install python
Check if Python Was Installed Properly
Regardless of the technique that you used to install Python, to check if Python was installed, open the Terminal and type:
$ python3 --version
Alternatively, you can go to the Applications folder and see if Python 3.X is installed.
Check if Pip is Installed
$ pip3 --version
If pip is not installed, you can run:
$ python3 get-pip.py
Check Where Python was Installed
$ which python
We now conclude this tutorial on how to install Python on MacOS. Please make sure to read my series on tutorials on Python SEO to dive deeper.
SEO Strategist at Tripadvisor, ex- Seek (Melbourne, Australia). Specialized in technical SEO. In a quest to programmatic SEO for large organizations through the use of Python, R and machine learning.