Install Python 3 on Mac
In this tutorial, we are going to install python3 in Mac OS. There are multiple ways to install like downloading from the official site or homebrew.
Check whether python2 installed or not
Initially, MacOS came preinstalled with Python 2, however, starting with Mac 10.15 this is no longer the case. And since Python 2 will no longer be officially supported as of January 1, 2020, you should really use Python 3 instead.
Check whether python3 already installed or not:
Before we start, make sure Python 3 isn’t already installed on your computer. Open up the command line via the Terminal application which is located at Applications -> Utilities -> Terminal.
$ python --version
Python version |
Xcode Installation:
The first step for Python 3 is to put in Apple’s Xcode program which is important for iOS improvement as nicely as most programming tasks. We will use XCode to put in Homebrew.
In your Terminal app, run the following command to install XCode and its command-line tools:
$ xcode-select --install
Install Homebrew
Next install Homebrew by copy/pasting the following command into Terminal and then type Enter:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To confirm Homebrew installed correctly, run this command:
$ brew doctor
Your system is ready to brew.
Install Python 3
Now we are ready to install the latest version of Python 3.
Type the below command to install it:
$ brew install python3
To check which version of Python 3 was installed, run the below command in Terminal:
$ python3 --version
Python 3.7.4
Finally, to run our new version of Python 3 open an interactive shall by:
Note: that it is still possible to run Python 2 by simply typing
python
: