16

The Monterey 12.3 upgrade removes Python 2.7 with no user warnings. Homebrew only knows about Python 3. What other ways are there to get Python 2 back up and running?

I'm not interested in hearing arguments about deprecation. We're not a dev shop, just a small mail order business with some internal scripts that need to work again.

5
  • Just remember to ensure that all your scripts use #! /usr/bin/env python not #! /usr/bin/python. TBH if you just make sure that print statements have brackets and unicode strings are handled correctly, your scripts should work in python3.
    – benwiggy
    Mar 17, 2022 at 9:55
  • @benwiggy - they didn't. Scripts were querying a SQLite database: returned as strings in Python 2, not in 3. Also, the database had '-' for missing numeric values, which Python 2 is fine comparing with a number, but 3 throws an exception
    – scruss
    Mar 20, 2022 at 1:14
  • thanks for question and answer, but, honestly, you can't stick to Python 2 indefinitely. The incompatibilities you mention seem easy to solve. There will be others, of course, but still... And SO is here to help! Jun 30, 2022 at 16:28
  • believe me, @WalterTross - they're not easy to solve, at least not in the very limited time I have to do so. Since I have the source of Python 2, I do believe I can stick with Python 2 indefinitely
    – scruss
    Jul 1, 2022 at 17:10

2 Answers 2

15

The Python Release Python 2.7.18 | Python.org download page has a macOS 64-bit installer download that replaces the missing interpreter.

4
  • Yes: that's the easiest and simplest way.
    – benwiggy
    Mar 17, 2022 at 9:53
  • It's good for me
    – Ven Shine
    Mar 25, 2022 at 7:27
  • 2
    Previous versions of MacOS had 2.7 at /usr/bin/python and installing it this way puts it at /usr/local/bin/python so you either need to make a symlink or potentially update the path in your scripts. Apr 8, 2022 at 18:31
  • Adding to what @JoelMellon said: If a script was hard-coding #!/usr/bin/python, you should update it to do #!/usr/bin/env python (or #!/usr/bin/env python2 or #!/usr/bin/env python3) instead, to make it more portable.
    – Maxpm
    Jan 13 at 16:21
4

MacPorts packages python27.

I also found an unofficial tap, if you must use Homebrew for some reason, in about 10 sec of searching.

You must log in to answer this question.

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