Getting started with ActivePython on macOS

  • Install Location: /Library/Frameworks/Python.framework/Versions/3.8 with links created in /usr/local/bin.

Running Python and the Interactive Shell

The ActivePython installer on macOS installs symlinks for running python, pythonw, and pydoc to /usr/local/bin.

If this directory is not already on your PATH you can add it manually as follows:

Add the following statement in your ~/.bash_profile file.

PATH=/usr/local/bin:$PATH; export PATH

Open the Terminal application (/Applications/Utilities/Terminal.app) and type python. (If you already had a terminal open you may need to start a new one to see the PATH changes, or reinitialize your ~/.bash_profile file using source ~/.bash_profile) You should see something like the following:

ActivePython 3.8.1.3801 (ActiveState Software Inc.) based on
Python 3.8.1 (default, Mar 21 2019, 09:33:37)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

You can use the Python shell to interactively run Python code. This can be a very useful development and debugging tool. Learn how to use Python’s built-in dir() and help() introspection functions to dive into Python objects. For example, try running the following:

>>> import os.path
>>> dir(os.path)
    ** outputs a list of members of os.path module...**
>>> help(os.path)
    ** outputs a MAN page-like description of the os.path module...**
>>> help(os.path.join)
    ** outputs help on the join function...**

Read the Python Tutorial for more information.

pythonw

On macOS, any process that provides a GUI (i.e. talks to the Aqua window manager) needs to be launched in a certain way. The pythonw command (just a stub that calls the actual Python executable as required) is provided for this purpose. If your Python code provides a GUI, launch it with pythonw instead of python. (There is a hack, but it is not recommended.)

GUI Programming

Tkinter is Python’s binding to the cross-platform Tk GUI toolkit. ActivePython includes Tkinter by default, but on macOS you must also install ActiveTcl to use Tkinter.

wxPython is another popular cross-platform GUI programming toolkit. It is available separately from http://www.wxpython.org/.