2

When updating Homebrew I got

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  python@2

What should I do? Is it safe? Will this affect the Python that comes with the macOS and break things?

qazwsx
  • 25,536
  • 30
  • 72
  • 106
  • If you use `pip` or `easy_install` to install packages for both Python 2 installations, it will cause problems. If you never install anything into the built-in Python, those problems won't arise. The only problem you might then have is accidentally running the built-in Python when you wanted to run the other one. As long as you know how to spot and debug that (can't import any installed packages) and how to solve/workaround it (fix your `PATH`, explicitly run `/usr/local/bin/python` instead of `/usr/bin/python`, etc.), you'll be fine. – abarnert Mar 12 '18 at 17:53
  • '... use pip or easy_install to install packages for both Python 2 installations ...' -- how does one tell? Does running 'pip install XXX' install XXX for both? – qazwsx Mar 12 '18 at 17:55
  • On the other hand, if you didn't actually want another Python 2, and the package was pulled in by some other package, you're probably safe _not_ linking it. The only problem you may run into is that the other package may create scripts that rely on the Python 2 being on the path. This is unlikely, but if it comes up, know how to recognize it. – abarnert Mar 12 '18 at 17:55
  • No, it doesn't install for both. Which one it installs to depends on which copy of `pip` or `easy_install` you run. The good news is, Apple's Python doesn't come with `pip` (you have to `sudo easy_install pip` to get it), and you should never need to use `easy_install`, so if you only use `pip`, you'll never touch the Apple Python. (This is a bit of a hacky thing to rely on, but it's worked consistently from OS X 10.5 to today, and it's simple, so if you don't want to learn things any deeper, I'd trust it.) – abarnert Mar 12 '18 at 17:56
  • I found that my 'pip' is the one at '/usr/local/bin/pip'. So I think I've only run 'pip install XXX' and installed packages for '/usr/local/bin/python'. – qazwsx Mar 12 '18 at 18:03
  • Well, that's not quite a guarantee. If you've installed `pip` for Apple's Python, it installs into `/usr/local/bin/pip`. (And if you installed it with `easy_install`, it'll even silently overwrite another `/usr/local/bin/pip` that was previously there!) As long as you either never install (`brew link`) another Python 2, or never install `pip` or any other packages for Apple's Python, you're safe—but if you do both all bets are off. – abarnert Mar 12 '18 at 18:08

0 Answers0