1

How do I install the release from python.org on my MacOS?

I downloaded the latest release of Python from the official website, verified the PGP signature, and now I want to install it -- but how?

user@host ~ % gpg --verify python-3.12.2-macos11.pkg.asc
gpg: assuming signed data in 'python-3.12.2-macos11.pkg'
gpg: Signature made Tue Feb  6 22:22:22 2024 GMT
gpg:                using RSA key 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
gpg: Good signature from "Ned Deily (Python release signing key) <[email protected]>" [unknown]
gpg:                 aka "Ned Deily (Python release signing key) <[email protected]>" [unknown]
gpg:                 aka "Ned Deily <[email protected]>" [unknown]
gpg:                 aka "keybase.io/nad <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 0D96 DF4D 4110 E5C4 3FBF  B17F 2D34 7EA6 AA65 421D
user@host ~ % 

I'm on a headless system connected over ssh. "Double clicking" or doing anything in the GUI is not an option.

How can I install this .pkg file and execute python to actually get a python interpreter shell?

1

1 Answer 1

4

Once you have downloaded the python .pkg from https://www.python.org/downloads/ you should be able to install it on the command line using the installer command.

Running

sudo installer -pkg path/to/python.pkg -target /

will install it directly from the command line.

You should then be able to call python using /usr/local/bin/python3.

Here is a screenshot showing what the official package from python.org installs.

screenshot of package contents

And this is the content of /usr/local/bin after the installer has run.

lrwxr-xr-x  1 root     wheel        78 Apr  8 21:13 python3-intel64@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3-intel64
lrwxr-xr-x  1 root     wheel        72 Apr  8 21:13 2to3-3.12@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/2to3-3.12
lrwxr-xr-x  1 root     wheel        72 Apr  8 21:13 pydoc3.12@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/pydoc3.12
lrwxr-xr-x  1 root     wheel        67 Apr  8 21:13 2to3@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/2to3
lrwxr-xr-x  1 root     wheel        70 Apr  8 21:13 python3@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3
lrwxr-xr-x  1 root     wheel        80 Apr  8 21:13 python3.12-config@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12-config
lrwxr-xr-x  1 root     wheel        68 Apr  8 21:13 idle3@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/idle3
lrwxr-xr-x  1 root     wheel        71 Apr  8 21:13 idle3.12@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/idle3.12
lrwxr-xr-x  1 root     wheel        81 Apr  8 21:13 python3.12-intel64@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12-intel64
lrwxr-xr-x  1 root     wheel        77 Apr  8 21:13 python3-config@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3-config
lrwxr-xr-x  1 root     wheel        73 Apr  8 21:13 python3.12@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
lrwxr-xr-x  1 root     wheel        69 Apr  8 21:13 pydoc3@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/pydoc3
lrwxrwxr-x  1 root     admin        70 Apr  8 21:13 pip3.12@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/pip3.12
lrwxrwxr-x  1 root     admin        67 Apr  8 21:13 pip3@ -> ../../../Library/Frameworks/Python.framework/Versions/3.12/bin/pip3
6
  • Ah, mine was put in /Users/maltfield/usr/local/bin/python3.12 (since I used -target CurrentUserHomeDirectory), but executing it still fails. I get an error dyld: Library not loaded: /Library/Frameworks/Python.framework/Versions/3.12/Python). Have you tried actually executing your binary? I still feel like I'm missing a step to install it properly. Commented Apr 8 at 19:20
  • 1
    @MichaelAltfield It worked for me. Looking at the path in your error message, it seems that Python doesn't really support a user-local installation (because the symlink points to /Library/...).
    – nohillside
    Commented Apr 8 at 19:22
  • hmm...that's unfortunate. I was trying to avoid -target / so it wouldn't cause conflicts with brew- or Apple-installed pythons Commented Apr 8 at 19:23
  • The only Apple-installed python would be from the CLT, which doesn't go in /usr/local. And if you are installing a python from Homebrew, why are you using the python.org package(s)? Commented Apr 8 at 20:05
  • @MarcWilson I'm doing this on a headless GitHub Actions Runner that is provided for free. It comes with Apple- and brew-provided python pre-installed. I'm installing the latest version from python.org because, unlike brew, it's actually cryptographically signed. Brew is notoriously insecure. Also building a python app via PyInstaller using the python.org version lets the release run on older versions of MacOS than the brew version. Commented Apr 9 at 2:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .