Installing Python on macOS with the official Python installer#
I usually use Homebrew on macOS, but I decided to try using the official Python installer based on this Twitter conversation.
My big fear was that it would add Yet Another Python to my system in a way that made the XKCD 1987 situation even worse!
I downloaded the installer using the prompt on the Python.org homepage (in the “Downloads” menu):

After running the installer and accepting the default options, a Python 3.10 folder was added to my /Applications
folder:

More importantly though, running python3
in my terminal now runs the version of Python that was installed by the installer - which lives in /Library/Frameworks/Python.framework/
:
1~ % which python32/Library/Frameworks/Python.framework/Versions/3.10/bin/python33~ % python34Python 3.10.2 (v3.10.2:a58ebcc701, Jan 13 2022, 14:50:16) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin5Type "help", "copyright", "credits" or "license" for more information.
I was confused as to how it had added itself to my path - a tip from Ned Deily (a Python release manager) helped me figure that out:
1~ % grep -d skip '3.10' ~/.*2/Users/simon/.zprofile:# Setting PATH for Python 3.103/Users/simon/.zprofile:PATH="/Library/Frameworks/Python.framework/Versions/3.10/bin:${PATH}"
So the installer added a line to my .zprofile
file adding the bin
directory for that release to my path.
Running python3.10
is the most specific way to execute that version of Python. I can install new command-line tools into that bin
directory like so:
1% python3.10 -m pip install google-drive-to-sqlite2Collecting google-drive-to-sqlite3 Downloading google_drive_to_sqlite-0.4-py3-none-any.whl (20 kB)4...5% google-drive-to-sqlite --version6google-drive-to-sqlite, version 0.47% which google-drive-to-sqlite8/Library/Frameworks/Python.framework/Versions/3.10/bin/google-drive-to-sqlite