Hacker News new | ask | show | jobs
by SjuulJanssen 2985 days ago
yes and it took me a while to fix things. I still need to maintain my python2 code
2 comments

pyenv is your friend. It manages the installation of multiple versions, and you can choose on a per-pipenv basis which one you want to use. A certain codebase requires 2.7.10, not 2.7.11? Pin it to 2.7.10 and it'll stay there forever, even if you upgrade the system or homebrew python.
Doesn't OSX come with python2 by default?
It does, what can break is what `python` points to.
This is un-broken as of 2018-03-09[1,2,3]. `brew install python` installs python3, but it only installs a link to this at `/usr/local/bin/python3`, not `/usr/local/bin/python` (as it did for a while).

In other words, `brew install python` now complies with PEP 394[4].

  $ brew install python
  …
  ==> Caveats
  Python has been installed as
    /usr/local/bin/python3

  Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
  `python3`, `python3-config`, `pip3` etc., respectively, have been installed into
    /usr/local/opt/python/libexec/bin
  …
  $ ls -l /usr/local/bin/python{,2,3}
  lrwxr-xr-x 1 osteele staff 38 Mar 22 11:23 /usr/local/bin/python -> ../Cellar/python@2/2.7.14_3/bin/python
  lrwxr-xr-x 1 osteele staff 39 Mar 22 11:23 /usr/local/bin/python2 -> ../Cellar/python@2/2.7.14_3/bin/python2
  lrwxr-xr-x 1 osteele staff 34 Mar 31 12:27 /usr/local/bin/python3 -> ../Cellar/python/3.6.5/bin/python3
[1] https://brew.sh/2018/04/09/homebrew-1.6.0/

[2] https://github.com/Homebrew/homebrew-core/issues/24812

[3] https://discourse.brew.sh/t/python-and-pep-394/1813

[4] https://www.python.org/dev/peps/pep-0394/