@@ -10,41 +10,46 @@ Using Python on a Mac
10
10
11
11
Python on a Mac running macOS is in principle very similar to Python on
12
12
any other Unix platform, but there are a number of additional features such as
13
- the IDE and the Package Manager that are worth pointing out.
13
+ the integrated development environment (IDE) and the Package Manager that are
14
+ worth pointing out.
15
+
14
16
15
17
.. _getting-osx :
18
+ .. _getting-and-installing-macpython :
16
19
17
- Getting and Installing MacPython
18
- ================================
20
+ Getting and Installing Python
21
+ =============================
19
22
20
23
macOS used to come with Python 2.7 pre-installed between versions
21
24
10.8 and `12.3 <https://developer.apple.com/documentation/macos-release-notes/macos-12_3-release-notes#Python >`_.
22
- You are invited to install the most recent version of Python 3 from the Python
23
- website ( https://www.python.org). A current "universal binary" build of Python,
24
- which runs natively on the Mac's new Intel and legacy PPC CPU's, is available
25
- there.
25
+ You are invited to install the most recent version of Python 3 from the ` Python
26
+ website < https://www.python.org/downloads/macos/> `__.
27
+ A current "universal2 binary" build of Python, which runs natively on the Mac's
28
+ new Apple Silicon and legacy Intel processors, is available there.
26
29
27
30
What you get after installing is a number of things:
28
31
29
- * A :file: ` Python 3.12 ` folder in your :file: `Applications ` folder. In here
32
+ * A | python_version_literal | folder in your :file: `Applications ` folder. In here
30
33
you find IDLE, the development environment that is a standard part of official
31
- Python distributions; and PythonLauncher , which handles double-clicking Python
34
+ Python distributions; and :program: ` Python Launcher ` , which handles double-clicking Python
32
35
scripts from the Finder.
33
36
34
37
* A framework :file: `/Library/Frameworks/Python.framework `, which includes the
35
38
Python executable and libraries. The installer adds this location to your shell
36
- path. To uninstall MacPython, you can simply remove these three things. A
37
- symlink to the Python executable is placed in /usr/local/bin/.
38
-
39
- The Apple-provided build of Python is installed in
40
- :file: `/System/Library/Frameworks/Python.framework ` and :file: `/usr/bin/python `,
41
- respectively. You should never modify or delete these, as they are
42
- Apple-controlled and are used by Apple- or third-party software. Remember that
43
- if you choose to install a newer Python version from python.org, you will have
44
- two different but functional Python installations on your computer, so it will
45
- be important that your paths and usages are consistent with what you want to do.
46
-
47
- IDLE includes a help menu that allows you to access Python documentation. If you
39
+ path. To uninstall Python, you can remove these three things. A
40
+ symlink to the Python executable is placed in :file: `/usr/local/bin/ `.
41
+
42
+ .. note ::
43
+
44
+ On macOS 10.8-12.3, the Apple-provided build of Python is installed in
45
+ :file: `/System/Library/Frameworks/Python.framework ` and :file: `/usr/bin/python `,
46
+ respectively. You should never modify or delete these, as they are
47
+ Apple-controlled and are used by Apple- or third-party software. Remember that
48
+ if you choose to install a newer Python version from python.org, you will have
49
+ two different but functional Python installations on your computer, so it will
50
+ be important that your paths and usages are consistent with what you want to do.
51
+
52
+ IDLE includes a Help menu that allows you to access Python documentation. If you
48
53
are completely new to Python you should start reading the tutorial introduction
49
54
in that document.
50
55
@@ -56,29 +61,29 @@ How to run a Python script
56
61
--------------------------
57
62
58
63
Your best way to get started with Python on macOS is through the IDLE
59
- integrated development environment, see section :ref: `ide ` and use the Help menu
64
+ integrated development environment; see section :ref: `ide ` and use the Help menu
60
65
when the IDE is running.
61
66
62
67
If you want to run Python scripts from the Terminal window command line or from
63
68
the Finder you first need an editor to create your script. macOS comes with a
64
- number of standard Unix command line editors, :program: `vim ` and
65
- :program: `emacs ` among them. If you want a more Mac-like editor,
66
- :program: `BBEdit ` or :program: ` TextWrangler ` from Bare Bones Software (see
67
- http ://www.barebones.com/products/bbedit/index.html) are good choices, as is
68
- :program: `TextMate ` (see https://macromates.com/ ). Other editors include
69
- :program: `Gvim ` (https://macvim.org/macvim/ ) and :program: `Aquamacs `
70
- (http ://aquamacs.org/ ).
69
+ number of standard Unix command line editors, :program: `vim `
70
+ :program: `nano ` among them. If you want a more Mac-like editor,
71
+ :program: `BBEdit ` from Bare Bones Software (see
72
+ https ://www.barebones.com/products/bbedit/index.html) are good choices, as is
73
+ :program: `TextMate ` (see https://macromates.com). Other editors include
74
+ :program: `MacVim ` (https://macvim.org) and :program: `Aquamacs `
75
+ (https ://aquamacs.org).
71
76
72
77
To run your script from the Terminal window you must make sure that
73
78
:file: `/usr/local/bin ` is in your shell search path.
74
79
75
80
To run your script from the Finder you have two options:
76
81
77
- * Drag it to :program: `PythonLauncher `
82
+ * Drag it to :program: `Python Launcher `.
78
83
79
- * Select :program: `PythonLauncher ` as the default application to open your
80
- script (or any .py script) through the finder Info window and double-click it.
81
- :program: `PythonLauncher ` has various preferences to control how your script is
84
+ * Select :program: `Python Launcher ` as the default application to open your
85
+ script (or any `` .py `` script) through the finder Info window and double-click it.
86
+ :program: `Python Launcher ` has various preferences to control how your script is
82
87
launched. Option-dragging allows you to change these for one invocation, or use
83
88
its Preferences menu to change things globally.
84
89
@@ -103,10 +108,11 @@ Python on macOS honors all standard Unix environment variables such as
103
108
:envvar: `PYTHONPATH `, but setting these variables for programs started from the
104
109
Finder is non-standard as the Finder does not read your :file: `.profile ` or
105
110
:file: `.cshrc ` at startup. You need to create a file
106
- :file: `~/.MacOSX/environment.plist `. See Apple's Technical Document QA1067 for
107
- details.
111
+ :file: `~/.MacOSX/environment.plist `. See Apple's
112
+ `Technical Q&A QA1067 <https://developer.apple.com/library/archive/qa/qa1067/_index.html >`__
113
+ for details.
108
114
109
- For more information on installation Python packages in MacPython , see section
115
+ For more information on installation Python packages, see section
110
116
:ref: `mac-package-manager `.
111
117
112
118
@@ -115,9 +121,9 @@ For more information on installation Python packages in MacPython, see section
115
121
The IDE
116
122
=======
117
123
118
- MacPython ships with the standard IDLE development environment. A good
124
+ Python ships with the standard IDLE development environment. A good
119
125
introduction to using IDLE can be found at
120
- http ://www.hashcollision.org/hkn/python/idle_intro/index.html.
126
+ https ://www.hashcollision.org/hkn/python/idle_intro/index.html.
121
127
122
128
123
129
.. _mac-package-manager :
@@ -130,8 +136,10 @@ This section has moved to the `Python Packaging User Guide`_.
130
136
.. _Python Packaging User Guide : https://packaging.python.org/en/latest/tutorials/installing-packages/
131
137
132
138
133
- GUI Programming on the Mac
134
- ==========================
139
+ .. _gui-programming-on-the-mac :
140
+
141
+ GUI Programming
142
+ ===============
135
143
136
144
There are several options for building GUI applications on the Mac with Python.
137
145
@@ -151,20 +159,25 @@ macOS. Packages and documentation are available from https://www.wxpython.org.
151
159
macOS. More information can be found at
152
160
https://riverbankcomputing.com/software/pyqt/intro.
153
161
162
+ *PySide * is another cross-platform Qt-based toolkit. More information at
163
+ https://www.qt.io/qt-for-python.
164
+
154
165
155
- Distributing Python Applications on the Mac
156
- ===========================================
166
+ .. _distributing-python-applications-on-the-mac :
167
+
168
+ Distributing Python Applications
169
+ ================================
157
170
158
171
The standard tool for deploying standalone Python applications on the Mac is
159
- :program: `py2app `. More information on installing and using py2app can be found
160
- at https://pypi.org/project/py2app/.
172
+ :program: `py2app `. More information on installing and using :program: ` py2app `
173
+ can be found at https://pypi.org/project/py2app/.
161
174
162
175
163
176
Other Resources
164
177
===============
165
178
166
- The MacPython mailing list is an excellent support resource for Python users and
167
- developers on the Mac:
179
+ The Pythonmac-SIG mailing list is an excellent support resource for Python users
180
+ and developers on the Mac:
168
181
169
182
https://www.python.org/community/sigs/current/pythonmac-sig/
170
183
0 commit comments