Python Setup and Usage, Release 3.9.5 To run your script from the Finder you have two options: • Drag it to$_{PythonLauncher}$ • Select$_{PythonLauncher}$ as the default application to open your script (or any .py script) through the finder Info window and double-click it. PythonLauncher has various preferences to control how your script is launched. Option-dragging allows you to change these for one invocation, or use its Preferences menu to change things globally. 4.1.2 Running scripts with a GUI With older versions of Python, there is one Mac OS X quirk that you need to be aware of: programs that talk to the Aqua window manager (in other words, anything that has a GUI) need to be run in a special way. Use$_{pythonw}$ instead of python to start such scripts. With Python 3.9, you can use either$_{python}$ or$_{pythonw}$. Python on OS X honors all standard Unix environment variables such as$_{PYTHONPATH}$ , but setting these variables for programs started from the Finder is non-standard as the Finder does not read your .profile or .cshrc at startup. You need to create a file$_{~/.MacOSX/environment.plist}$ . See Apple’s Technical Document QA1067 for details. 4.1.3 Configuration For more information on installation Python packages in MacPython, see section Installing Additional Python Pack- ages . MacPython ships with the standard IDLE development environment. A good introduction to using IDLE can be found at http://www.hashcollision.org/hkn/python/idle_intro/index.html. 4.2 The IDE 4.3 Installing Additional Python Packages There are several methods to install additional Python packages: There are several options for building GUI applications on the Mac with Python. • Packages can be installed via the standard Python distutils mode ($_{python setup.py install}$ ). • Many packages can also be installed via the$_{setuptools}$ extension or$_{pip}$ wrapper, see https://pip.pypa.io/. 4.4 GUI Programming on the Mac PyObjC is a Python binding to Apple’s Objective-C/Cocoa framework, which is the foundation of most modern Mac development. Information on PyObjC is available from https://pypi.org/project/pyobjc/. The standard Python GUI toolkit is $_{tkinter}$, based on the cross-platform Tk toolkit (https://www.tcl.tk). An Aqua-native version of Tk is bundled with OS X by Apple, and the latest version can be downloaded and installed from https://www.activestate.com; it can also be built from source. wxPython is another popular cross-platform GUI toolkit that runs natively on Mac OS X. Packages and documentation are available from https://www.wxpython.org. PyQt is another popular cross-platform GUI toolkit that runs natively on Mac OS X. More information can be found at https://riverbankcomputing.com/software/pyqt/intro. Chapter 4. Using Python on a Macintosh 36