1

I want the python command to work in the zsh terminal and launch python 2.7.

Please Note

  • Python 2 is NOT pre-installed in MacOS. That ended with v12 MacOS Monterey.
  • I am NOT looking for Python 3. I already have that, the python3 command works and I do not want 'python' to be an alias for it.
  • I ran "pyenv install 2.7.18". The 'python' command still does not work and pyenv shoving python2 into some subdirectory of a single user was never what I wanted. When I enter "which python3" it's in /usr/local/bin. I want a command that installs python 2.7 into a system-wide directory.

I don't want to install python 2.7 per-user and have to edit every .zshrc on every system to add an alias to some user subdirectory.

How, for the love of God, do you install python 2.7, system-wide on MacOS Monterey, so the 'python' command just works?

Scott Bishop
  • 119
  • 8
  • Does this answer your question? [Install python@2 on a Mac after python 2 support has ended on Homebrew](https://stackoverflow.com/questions/60650325/install-python2-on-a-mac-after-python-2-support-has-ended-on-homebrew). If not, when I google "mac install python 2.7", I get a bunch of hits. – Code-Apprentice May 26 '22 at 15:30
  • @rid Pyenv installed python2.7 into a subdirectory of the current user. If that user is removed or starts deleting things from their personal directory then the soft-link will break. I want python installed system-wide the way every other normal command is. – Scott Bishop May 26 '22 at 15:34
  • You can create a symlink `/usr/local/bin/python` to whatever you like, if nothing else. – chepner May 26 '22 at 15:37
  • @Code-Apprentice No, that answer refers to homebrew solutions that no longer work. – Scott Bishop May 26 '22 at 15:53
  • @chepner Creating a system-wide symlink to a user subdirectory is not a safe way to install an application. – Scott Bishop May 26 '22 at 15:54
  • 1
    Using Python 2 at all is arguably unsafe, unless you hav somebody other than the PSF providing security updates for you. – chepner May 26 '22 at 16:02
  • @chepner I agree and I only use Python 3 when I'm writing new stuff. But I have inherited a large amount of legacy scripts in Python 2 and shell scripts that expect to run them using 'python' as the command. – Scott Bishop May 26 '22 at 16:04
  • 1
    Who needs to run them? I would just set up a virtual environment rather than figure out how to "properly" install unsupported software globally. – chepner May 26 '22 at 16:17

0 Answers0