Python is a popular programming language that is widely used by both beginners and professional developers. Modern versions of Mac OS support Python 2.7.x (or Python 2.6.1 in older versions), but many users need to upgrade to Python 3.6 or 3.7.
Today I will explain how to install the Python 3 update on a Mac in two different ways.
See full list on dummies.com.
Note that I mean “install update” rather than “upgrade”, since Python 2 will remain on the Mac with this method. Some Mac programs require Python 2, and when upgrading they may start to malfunction or stop working altogether. Therefore, we will not update the installed version, but install Python 3 in parallel. Python 3 and Python 2 can coexist on the same Mac without conflicts, just the commands will differ slightly.
How to install Python 3 in macOS with Installer
- When using python in IDLE on Mac, each python installation has it’s own /lib/site-packages for 3rd party modules. Depending on your installation method (using the regular pip install package-name ) terminal won’t allow you to import them when using IDLE.
- Installers are available for the latest Python 3 and Python 2 releases that will work on all Macs that run Mac OS X 10.5 and later. Python releases include IDLE, Python's built-in interactive development environment. If you download and install Python from the release page, you may also need to download and install a newer version of Tcl/Tk for OS X.
- If you are using Python from a python.org 64-bit/32-bit Python installer for Mac OS X 10.6 and later, you should only use IDLE or tkinter with an updated third-party Tcl/Tk 8.5, like ActiveTcl 8.5 installed.
The easiest way is to download the Python installer from the python.org website.
- Visit Python.org and download the latest available Python installer file;
- Run the downloaded file and install Python 3.x on Mac.
- Python 3.6.x requires about 100MB of available disk space. The installation process is very fast;
- When Python 3 is installed, you will see the Python3 folder in /Applications on your Mac. You will also see IDLE in the /Applications.
Next method will show you how to install Python 3.x on a Mac through Homebrew.
How to install Python 3 using Homebrew
Installing an updated version of Python 3 through Homebrew is extremely simple. Of course, Homebrew should be installed on your computer, however, if you are interested in this method, then you probably have already used the program more than once.
Read more:How to Format USB for macOS and Windows?
If you haven’t Homebrew in your system, you can take script for Homebrew installing here. This script installs Homebrew to /usr/local so that you don’t need “sudo” when you brew install. It is a careful script; it can be run even if you have stuff installed to /usr/local already. It tells you exactly what it will do before it does it too. You have to confirm everything it will do before it starts.
Now to install Python 3 via Homebrew, run the following command in Terminal:
When Python 3 is installed on a Mac, you can start the program with:
In any case, after installing Python 3 on a computer, the version of Python 2.7 will still remain on it, and you will be able to use it.
How to Find out the Installed Version of Python
Open the Terminal program and use the following command:
Python For Mac Idle Upgrade
In most cases, Python 2.7.x will be installed on macOS: either 2.7.4 or 2.7.10.
If you installed the Python update, you can check the version with the following command:
Once again, both versions of Python can coexist without conflicts.
Note: Once again, I want to remind you that you do not need to upgrade Python 2.x to Python 3.x, because this can lead to program malfunctions. Just install the updated version in parallel.
Python for Mac OS X
Using Python On Mac
Python comes pre-installed on Mac OS X so it is easy to startusing. However, to take advantage of the latest versions ofPython, you will need to download and install newer versionsalongside the system ones. The easiest way to do that is toinstall one of the binary installers for OS X from thePython Download page. Installers areavailable for the latest Python 3 and Python 2 releases thatwill work on all Macs that run Mac OS X 10.5 and later.
Python releases include IDLE, Python's built-in interactivedevelopment environment. If you download and install Pythonfrom the release page, you may also need to download and installa newer version of Tcl/Tk for OS X. See theIDLE and Tkinter on OS X page formore information.
You can run a Python interpreter by double-clicking onApplications / Utilities / Terminal and typing python3 (if you'veinstalled a version of Python 3) or python (to use Python 2) inthe window that opens up. You can also launch IDLE for the Pythonversion you have installed by double-clicking its icon inthe appropriate Python version folder in the Applications folderor you can also just type idle3 or idle in a terminal window.
There are many thousands of additional Python software packagesavailable through PyPI, the PythonPackage Index. We recommend you use thepip tool to simplifyinstalling and managing additional packages. pip is includedwith Python 3.4 releases; for earlier releases, follow the pipinstall instructions.
Among the packages available through PyPI are some that arespecifically for OS X environments. Among these are:
- pyobjc which providesa bridge between Python and Objective-C, allowing you to writefull-featured native Cocoa applications in pure Python.
- py2app which allowsyou to make standalone OS X double-clickable application bundlesand plugins from Python scripts.
Idle Ide Download
For more information about Python on OS X, see the mailing list and archivesfor thePython-Macintosh Special Interest Group.
Python For Mac Idle Software
Alternative Packages for Mac OS X.
- ActiveState ActivePython(commercial and community versions, including scientific computing modules).
- Enthought Python DistributionThe Enthought Python Distribution provides scientists with a comprehensive setof tools to perform rigorous data analysis and visualization.
Python and a comprehensive set of third-party packages and libraries are alsoavailable from several open source package manager projects for OS X,including: