Python is a popular programming language for creating applications on desktop platforms as well as the web. It's also known as a great place for new coders to start, based on its easy syntax and flexibility. We'll show you how to install the most recent version of Python on your Mac.
Instructions in this article apply to the latest versions of Python and macOS.
Which Python Version to Install on macOS
Python comes pre-installed on macOS, but the built-in version is specific to the version of macOS you're currently running. This means it's only updated when you receive an OS update from Apple. So, if you choose to use the version built into macOS, you may be running a version that's older than the current one.
Your other alternative is to install an up-to-date version directly from the Python project. Doing this comes with its own caveats, namely that you'll need to keep up with new releases on your own.
Before deciding this, consider the following:Will your Python programs be solely for your own use, on your own Mac? If so, the built-in version is probably sufficient.Are you going to release your programs for use on a specific platform? When this is the case, it depends on how that platform tracks Python releases (or not). If you're targeting only macOS with your code, then the built-in version is actually a good choice, as you'll always know that the version you're using is the one that your users will have as well. However, if you're writing a web application, you'll need to consider what version of Python your web hosting company supports.Some operating systems, such as Linux, will follow the most recent release of Python closely. In this instance you can also use more recent versions, in order to take advantage of newer features.
Should you decide that you need the latest and greatest after thinking through the above points, the following section will show you how to get it installed in macOS.
Installing Python on macOS
The Python project makes regular releases of Python in standard .PKG format. Follow the following steps to install the standard Python distribution on your Mac:
Grab the latest release from the Python website. Unless you're on an older machine and have to use a previous version of macOS for some reason, you can download the 64-bit installer file.
The download is the standard macOS .PKG format. Click the installer file to proceed.
The first screen provides some information on the install. Click Continue to move along.
Click Continue on the following page as well, which is a notice that the project will stop providing support for 32-bit installers from v3.8 onward.
The next screen asks you to accept the open-source license for Python. Click Continue and then click Agree.
Select a destination for the install on the following screen. You can click Install to place it on your main drive or click Customize to place it elsewhere.
Now the installer starts copying the files, and the progress bar tells you when it's complete.
Once the installation is finished, the app's folder opens in Finder.
Confirming Your Python Installation
To quickly confirm your Python installation is working correctly, try the following command in Terminal:python --versionPython 3.7.4
If you want to further confirm things, try running a simple Python script. Enter (or paste) the following code into an empty text file and naming it "hello-world.py":print ("Hello World!")
Now, at the command prompt, run the following:python /path/to/hello-world.pyHello World!
If you get the above output, your up-to-date Python installation is ready to go.