27

For some reason it's no symlinking when I run `brew link python.' I'm getting the following error and I do what it tells me to do but it's not working. I have tried doing what it tells me to do but maybe I'm not putting the formula_name right. Also, when I do 'which python' it doesn't point to the Homebrew python and I need help fixing that as well.

    Linking /usr/local/Cellar/python/2.7.3...Warning: Could not link python. 
    Unlinking....

   Error: Could not symlink file: /usr/local/Cellar/python/2.7.3/bin/smtpd.py
   Target /usr/local/bin/smtpd2.py already exists. You may need to delete it.
   To force the link and delete this file, do:
      brew link --overwrite formula_name
Jennifer
  • 297
  • 2
  • 5
  • 9

1 Answers1

62

Did you try brew link --overwrite python?

Michael Mior
  • 28,107
  • 9
  • 89
  • 113
  • This worked for me to. Does this problem happen because of a prior python install? – algorithmicCoder Dec 04 '12 at 02:01
  • Most likely, yes. If you've installed Python manually Homebrew is smart enough to know and warn you before it destroys anything. – Michael Mior Dec 04 '12 at 03:17
  • 2
    this doesn't work for me actually. you have to remove each conflicting file eg. smtpd2.py then remove each one that it complains about (idle 2to3 etc.) until they are all gone. then it will do it. --overwrite doesn't have any effect – Chris Sattinger Apr 01 '13 at 13:45
  • 1
    @felix - maybe you have permissions issues - chowning /usr/local recursively to your user first would help, and overwrite option would then probably work. – RichVel Sep 24 '13 at 11:15
  • In general, you might want to try `brew doctor` to see if Homebrew finds any issues with your installation. – Michael Mior Sep 24 '13 at 18:42
  • 3
    Maybe first do `brew link --overwrite --dry-run python` to know beforehand which files will be removed – Urosh T. May 30 '20 at 19:24