macOS installs Python 2 (outdated) by default, for compatibility reasons, making it bachelor every bit /usr/bin/python.

If you install Xcode, the Apple tree Development IDE, it installs Python 3 in /usr/bin/python3. In this case you tin run python3 on your terminal to bank check the exact version installed, and if it's recent enough you might be already set upwards.

Python 3 is the one we're going to utilise for modern Python development.

Yet yous have little control over the version number you run, every bit Apple tree updates it only with new Xcode releases.

In my instance I had Python 3.8, but Python 3.9 was available to be installed.

One option is to use Homebrew to install the latest Python release.

Another option is to use the official Python packages and that's the approach we'll follow.

Go to https://www.python.org, choose the Downloads menu, hover "Mac OS 10" and a panel with a link to download the official bundle will announced:

Click that, and run the installer:

Click "Continue":

So click "Continue" again. A new console will appear with an interesting recap on the history of Python and its governance:

Python was created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands equally a successor of a language called ABC. Guido remains Python'south principal author, although it includes many contributions from others.

In 1995, Guido continued his work on Python at the Corporation for National Inquiry Initiatives (CNRI, see http://world wide web.cnri.reston.va.united states) in Reston, Virginia where he released several versions of the software.

In May 2000, Guido and the Python core development team moved to BeOpen.com to grade the BeOpen PythonLabs team. In October of the same year, the PythonLabs team moved to Digital Creations (now Zope Corporation, see http://www.zope.org). In 2001, the Python Software Foundation (PSF, meet http://www.python.org/psf/) was formed, a not-profit organization created specifically to ain Python-related Intellectual Property. Zope Corporation is a sponsoring member of the PSF.

And so you lot can read the Python license. Python is open source, and released with the Python Software Foundation License Version 2.

This license is GPL-compatible, which means you can combine Python with software that is GPL, Python itself is not GPL. The GPL license has some problems related to the fact that all software derived from GPL software must be released every bit GPL equally well, and the source code of the software must be distributed to anyone that wants access to it.

That's not the case for your Python programs. You can release the source if you want, but it's not required.

Concur to the license:

And move to the installation phase:

When it's finally installed, Python is installed as /usr/bin/python3

If you take Xcode installed, this will overwrite the former version that Xcode installed.

Running python3 in the macOS terminal opens the Python iii.nine interpreter nosotros just installed:

You will now likewise notice a new folder under "/Applications/Python three.9" (change that with your verbal version number), with some files:

As the instructions said in the final installation panel, you need to run the "Install Certificates.command" to install the SSL certificates needed past Python.

This is because Python includes its own private copy of OpenSSL ane.1.1, and we need to install a curated packet of default root certificates from the third-party certifi package.

Certifi provides Mozilla'southward carefully curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts

Double-click on Install Certificates to run information technology, and information technology volition to its chore quickly:

The other files contained in that folder are IDLE, an application that opens the Python interpreter in its own window:

Then we take a link to the official documentation, the license, and Python Launcher, an utility that lets you to locate and manage dissimilar Python versions installed on the organisation, and instruct scripts to use a specific version.

Call back to non be confused past having the python control on your system that points to the old Python ii. It might be a source of bug.

I recommend having a beat allonym to execute python3 each time y'all run python.

With the Fish shell, you tin can run:

            alias python              "python3"              alias pip              "pip3"              funcsave python funcsave pip          

directly in the final.

Also, make sure the pip binaries are in your shell path, to run them easily:

            set PATH ~/Library/Python/3.9/bin $PATH          

(change three.9 with your current version)

With Zsh, you demand to add together the alias to the .zshrc file in your abode folder:

          alias python="python3"        

With Bash, you lot need to add the alias to the .bashrc file in your home folder:

          alias python="python3"        

At present yous can run python and it will point to the Python 3 version you just installed.

I found that the easiest style to run pip (the Python parcel managing director) is to use python -g pip <Control> rather than pip <COMMAND>, for case:

          python -k pip install django        

And you should ever apply a virtual surround with venv when doing so.