Installing Python from python.org

The easiest and most obvious (to me) way to install the latest version of Python on either Mac or Windows is:

  1. Go to python.org
  2. Hover over the “Downloads” link in the navigation.
  3. This will detect if you are on Mac or Windows and present you with a button called “Python 3.11.0” (or whatever the latest version is).
  4. Click that button. This downloads an installer.
  5. Run the installer.

That’s it. Done.

How long does that take?

I just did this on my Mac laptop and timed it.

It took a whopping 1 minute 13 seconds to:

  • Do everything above
  • Open a new terminal window
  • Run python3 --version to verify that the new version was installed.

What if I want multiple versions?

Well, sure. I have multiple versions.

The above instructions put Python here: /Library/Frameworks/Python.framework/Versions/3.11/bin/

In that directory, there’s python3, which is really a link to python3.11.

I also have versions of Python 3.10 and 3.7 installed currently, and they respectfully have python3.10 and python3.7 executables. And those are still in my PATH, so I can run them whenever I want.

This also allows me to set up virtual environments using the older versions, if needed. Also, tox, which I use for testing regularly, can see these other versions just fine.

How did Python 3.11 become the default?

I’m pretty sure it’s because the installer added this snippet to my .zprofile:

# Setting PATH for Python 3.11
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"
export PATH

I still see older versions in there that I don’t even have installed anymore.

What if I want to update the version?

Good thinking. My current Python 3.10 is at 3.10.7:

$ python3.10 --version
Python 3.10.7

Let’s check for updates:

  • Head to python.org/downloads, or just python.org and click on “Downloads” instead of hovering.

  • Checking the recent releases, I see that there was a 3.10.8 released on Oct 11, 2022. Great.

  • Click “download”. Scroll to the bottom.

  • Click the download link for the “macOS blah blah” installer.

  • Run that.

Re-run my check from above:

$ python3.10 --version 
Python 3.10.8

Awesome. That took another minute.

Did updated 3.10 change the default?

Apparently not, but it’s good to check.

$ python3 --version
Python 3.11.0

Of course, if it had, I would just edit .zprofile and move the 3.11 stuff to below the 3.10 stuff.

What about other ways to install Python?

There are other ways, and I’ve tried many of them.

However, my method takes about 1 minute, and does everything I need. I don’t really need it to be faster.

Some of my thoughts on other ways to install Python:

homebrew
If you are already a homebrew user, great. You can use that. But I wouldn’t recommend installing homebrew just to install Python.
pyenv
pyenv is a tool to manage multiple Python versions. However, it’s not a novice tool. It modifies PATH and uses shims and other methods that can confuse users and other tools. It can install and update Python also, but at a cost of complexity. Bottom line: know what you are doing before attempting pyenv. Not for beginners.

This seems like a Mac tutorial. You said “or Windows”

Yes. The details of the install path and such are Mac specific in this post.

However, I also run several Windows machines and install there also with the python.org installer.

Changes to the process for Windows:

  • When running the installer, hit “Advanced Features” and check “Add Python to environment variables”.
  • The executable is python and not python3.
    • I get around this oddity by just setting up an alias in my .zshrc
  • Path is more like C:/Users/okken/AppData/Local/Programs/Python/Python311/python.
  • Since the different executables aren’t named, I utilize the py to launch different versions if needed manually:
    • py -3.11
    • py -3.10
    • etc.

So there are details and behind the scenes differences.

However, the installer just works.

I just tested the install on a Windows box and it went really smoothly.

But do rememeber to hit “Advanced Features” and check “Add Python to environment variables”.

Feedback

Feel free to @ me: @brianokken