Homebrew , python installing

34,589

Solution 1

Sounds like a permissions issue with /usr/local.

### Makes you owner of /usr/local 
$ sudo chown -R `whoami` /usr/local

### Force uninstalls failed python
$ brew uninstall -f python

### Clear the brew cache
$ rm -rf `brew --cache`

### Recreate the brew cache
$ mkdir `brew --cache`

### Cleanup - cleans up old homebrew files
$ brew cleanup

### Prune - removes dead symlinks in homebrew
$ brew prune

### Doctor - runs homebrew checks for common error causing issues
$ brew doctor

########
### Google and follow steps to fix what `brew doctor` came back with
########

### Reinstall python
$ brew install python

Solution 2

Did you try brew link --overwrite python? This worked for me without having to uninstall python - see this question for more details.

Share:
34,589
Andrey Baryshnikov
Author by

Andrey Baryshnikov

While I was a child I'd loved to create things with lego. Nowadays I express my love in programming - I love to build things with my own hands and brain :)

Updated on August 21, 2020

Comments

  • Andrey Baryshnikov
    Andrey Baryshnikov almost 4 years

    i got an error while trying to install python throught homebrew. brew says what it failed to link python , here is output:

    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/smtpd2.py
    /usr/local/bin/smtpd2.py may already exist.
    /usr/local/bin may not be writable.
    

    ls -la on /usr/bin and bin rights :

    The drwxrwxrwx  26 root             admin  884 26 Oct 16:03 bin
    

    And smtpd2.py is exists.. How can i fix it? Delete smtpd2.py ?

  • Andrey Baryshnikov
    Andrey Baryshnikov over 11 years
    Thank you, this helped to install python through homebrew:)
  • tbarbe
    tbarbe over 11 years
    Im at brew doctor and getting this - can you help? Warning: python is symlinked to python
  • TomFuertes
    TomFuertes over 11 years
    try following the above, but running rm -rf /usr/local/Cellar/python between the uninstall and cache clear lines
  • smessing
    smessing about 11 years
    If it is a permissions issue, after fixing /usr/local you can also simply run brew link python or brew link --overwrite python. Using brew link --dry-run --overwrite python will tell you what things will change without doing it.
  • vaughan
    vaughan about 11 years
    Thanks, brew prune fixed my issues!
  • RichVel
    RichVel almost 11 years
    I had to chown /usr/local as in accepted answer, then this command worked well.
  • mateor
    mateor about 8 years
    New command is brew linkapps python to symlink to Applications
  • Dipankar
    Dipankar over 6 years
    This worked. Additionally, I had to remove /usr/local/lib/python2.7/site-packages