DAGDA SEARCH | Back to results | Support

5. Using Python on macOS — Python 3.15.2 documentation

Source: https://docs.python.org/3/using/mac.html

Navigation

5. Using Python on macOS

This document aims to give an overview of macOS-specific behavior you should know about to get started with Python on Mac computers. Python on a Mac running macOS is very similar to Python on other Unix-derived platforms, but there are some differences in installation and some features.

There are various ways to obtain and install Python for macOS. Pre-built versions of the most recent versions of Python are available from a number of distributors. Much of this document describes use of the Pythons provided by the CPython release team for download from the python.org website. See Alternative distributions for some other options.

5.1. Using Python for macOS from python.org

5.1.1. Installation steps

For current Python versions (other than those in security status), the release team produces a Python for macOS installer package for each new release. A list of available installers is provided on the macOS downloads page. We recommend using the most recent supported Python version where possible. Current installers provide a universal2 binary build of Python which runs natively on all Macs (Apple Silicon and Intel) that are supported by a wide range of macOS versions, currently typically from at least macOS 10.15 Catalina on.

The downloaded file is a standard macOS installer package file (.pkg). File integrity information (such as checksum, size, and Sigstore signature) for each file is included on the release download page. Installer packages and their contents are signed and notarized with Python Software Foundation Apple Developer ID certificates to meet macOS Gatekeeper requirements.

For a default installation, double-click on the downloaded installer package file. This should launch the standard macOS Installer app and display the first of several installer steps.

../_images/mac_installer_01_introduction.png

Clicking on the Continue button brings up the Read Me for this installer. Besides other important information, the Read Me documents which Python version is going to be installed and on what versions of macOS it is supported. You may need to scroll through to read the whole file. By default, this Read Me will also be installed in /Applications/Python 3.15/ and available to read anytime.

../_images/mac_installer_02_readme.png

Clicking on Continue proceeds to display the license for Python and for other included software. You will then need to Agree to the license terms before proceeding to the next step. This license file will also be installed and available to be read later.

../_images/mac_installer_03_license.png

After the license terms are accepted, the next step is the Installation Type display. For most uses, the standard set of installation operations is appropriate.

../_images/mac_installer_04_installation_type.png

By pressing the Customize button, you can choose to omit or select certain package components of the installer. Click on each package name to see a description of what it installs. For details of the optional free-threaded feature, which is installed by default, see Installing free-threaded binaries.

../_images/mac_installer_05_custom_install.png

In either case, clicking Install will begin the install process by asking permission to install new software. A macOS user name with Administrator privilege is needed as the installed Python will be available to all users of the Mac.

When the installation is complete, the Summary window will appear.

../_images/mac_installer_06_summary.png

Double-click on the Install Certificates.command icon or file in the /Applications/Python 3.15/ window to complete the installation.

../_images/mac_installer_07_applications.png

This will open a temporary Terminal shell window that will use the new Python to download and install SSL root certificates for its use.

../_images/mac_installer_08_install_certificates.png

If Successfully installed certifi and update complete appear in the terminal window, the installation is complete. Close this terminal window and the installer window.

A default install will include:

Note

Recent versions of macOS include a python3 command in /usr/bin/python3 that links to a usually older and incomplete version of Python provided by and for use by the Apple development tools, Xcode or the Command Line Tools for Xcode. You should never modify or attempt to delete this installation, as it is Apple-controlled and is used by Apple-provided or third-party software. If you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer that can co-exist. The default installer options should ensure that its python3 will be used instead of the system python3.

5.1.2. How to run a Python script

There are two ways to invoke the Python interpreter. If you are familiar with using a Unix shell in a terminal window, you can invoke python3.15 or python3 optionally followed by one or more command line options (described in Command line and environment). The Python tutorial also has a useful section on using Python interactively from a shell.

You can also invoke the interpreter through an integrated development environment. IDLE — Python editor and shell is a basic editor and interpreter environment which is included with the standard distribution of Python. IDLE includes a Help menu that allows you to access Python documentation. If you are completely new to Python, you can read the tutorial introduction in that document.

There are many other editors and IDEs available, see Editors and IDEs for more information.

To run a Python script file from the terminal window, you can invoke the interpreter with the name of the script file:

python3.15 myscript.py

To run your script from the Finder, you can either:

Be aware that running the script directly from the macOS Finder might produce different results than when running from a terminal window as the script will not be run in the usual shell environment including any setting of environment variables in shell profiles. And, as with any other script or program, be certain of what you are about to run.

5.2. Alternative distributions

Besides the standard python.org for macOS installer, there are third-party distributions for macOS that may include additional functionality. Some popular distributions and their key features:

ActivePython

Installer with multi-platform compatibility, documentation

Anaconda

Popular scientific modules (such as numpy, scipy, and pandas) and the conda package manager.

Homebrew

Package manager for macOS including multiple versions of Python and many third-party Python-based packages (including numpy, scipy, and pandas).

MacPorts

Another package manager for macOS including multiple versions of Python and many third-party Python-based packages. May include pre-built versions of Python and many packages for older versions of macOS.

Note that distributions might not include the latest versions of Python or other libraries, and are not maintained or supported by the core Python team.

5.3. Installing additional Python packages

Refer to the Python Packaging User Guide for more information.

5.4. GUI programming

There are several options for building GUI applications on the Mac with Python.

The standard Python GUI toolkit is tkinter, based on the cross-platform Tk toolkit (https://www.tcl.tk). A macOS-native version of Tk is included with the installer.

PyObjC is a Python binding to Apple’s Objective-C/Cocoa framework. Information on PyObjC is available from pyobjc.

A number of alternative macOS GUI toolkits are available including:

5.5. Advanced topics

5.5.1. Installing free-threaded binaries

Added in version 3.13.

Changed in version 3.15: Free-threading support is now installed by default.

The python.org Python for macOS installer package installs, by default, an additional build of Python 3.15 that supports free threading (running with the global interpreter lock disabled). Check the release page on python.org for possible updated information.

The free-threaded mode is working and continues to be improved, but there is some additional overhead in single-threaded workloads compared to the regular build. Additionally, third-party packages, in particular ones with an extension module, may not be ready for use in a free-threaded build, and will re-enable the GIL. As of Python 3.15, free-threading support is installed by default. It is packaged as a separate install option, which can be deselected by clicking the Customize button on the Installation Type step of the installer as described above.

../_images/mac_installer_09_custom_install_free_threaded.png

If the box next to the Free-threaded Python package name is checked (as it is by default), a separate PythonT.framework will also be installed alongside the normal Python.framework in /Library/Frameworks. This configuration allows a free-threaded Python 3.15 build to co-exist on your system with a traditional (GIL only) Python 3.15 build with minimal risk while installing or testing. This installation layout may change in future releases.

Known cautions and limitations:

5.5.2. Installing using the command line

If you want to use automation to install the python.org installer package (rather than by using the familiar macOS Installer GUI app), the macOS command line installer utility lets you select non-default options, too. If you are not familiar with installer, it can be somewhat cryptic (see man installer for more information). As an example, the following shell snippet shows one way to do it, using the 3.15.0b2 release and deselecting the free-threaded interpreter option:

RELEASE="python-3.15.0b2-macos11.pkg"

# download installer pkg
curl -O https://www.python.org/ftp/python/3.15.0/${RELEASE}

# create installer choicechanges to customize the install:
#    disable the PythonTFramework-3.15 package
#    while accepting the other defaults (install all other packages)
cat > ./choicechanges.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
        <dict>
                <key>attributeSetting</key>
                <integer>0</integer>
                <key>choiceAttribute</key>
                <string>selected</string>
                <key>choiceIdentifier</key>
                <string>org.python.Python.PythonTFramework-3.15</string>
        </dict>
</array>
</plist>
EOF

sudo installer -pkg ./${RELEASE} -applyChoiceChangesXML ./choicechanges.plist -target /

After a default install, you can test that both builds are available with something like:

$ # test that the free-threaded interpreter was installed if the Unix Command Tools package was enabled
$ /usr/local/bin/python3.15t -VV
Python 3.15.0b2 free-threading build (v3.15.0b2:3a83b172af, Jun  5 2024, 12:57:31) [Clang 15.0.0 (clang-1500.3.9.4)]
$ #    and the traditional interpreter
$ /usr/local/bin/python3.15 -VV
Python 3.15.0b2 (v3.15.0b2:3a83b172af, Jun  5 2024, 12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]
$ # test that they are also available without the prefix if /usr/local/bin is on $PATH
$ python3.15t -VV
Python 3.15.0b2 free-threading build (v3.15.0b2:3a83b172af, Jun  5 2024, 12:57:31) [Clang 15.0.0 (clang-1500.3.9.4)]
$ python3.15 -VV
Python 3.15.0b2 (v3.15.0b2:3a83b172af, Jun  5 2024, 12:50:24) [Clang 15.0.0 (clang-1500.3.9.4)]

Note

Current python.org installers only install to fixed locations like /Library/Frameworks/, /Applications, and /usr/local/bin. You cannot use the installer -domain option to install to other locations.

5.5.3. Distributing Python applications

A range of tools exist for converting your Python code into a standalone distributable application:

5.5.4. App Store compliance

Apps submitted for distribution through the macOS App Store must pass Apple’s app review process. This process includes a set of automated validation rules that inspect the submitted application bundle for problematic code.

The Python standard library contains some code that is known to violate these automated rules. While these violations appear to be false positives, Apple’s review rules cannot be challenged. Therefore, it is necessary to modify the Python standard library for an app to pass App Store review.

The Python source tree contains a patch file that will remove all code that is known to cause issues with the App Store review process. This patch is applied automatically when CPython is configured with the --with-app-store-compliance option.

This patch is not normally required to use CPython on a Mac; nor is it required if you are distributing an app outside the macOS App Store. It is only required if you are using the macOS App Store as a distribution channel.

5.6. Other resources

The python.org Help page has links to many useful resources. The Pythonmac-SIG mailing list is another support resource specifically for Python users and developers on the Mac.

Table of Contents

Previous topic

4. Using Python on Windows

Next topic

6. Using Python on Android

This page

«

Navigation

© Copyright 2001 Python Software Foundation.
This page is licensed under the Python Software Foundation License Version 2.
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
See History and License for more information.

The Python Software Foundation is a non-profit corporation. Please donate.

Last updated on Nov 29, 2026 (03:42 UTC). Found a bug?
Created using Sphinx 9.1.1.