Paradox
Paradox

Reputation: 2035

Brew error upgrading python

I've been having a consistent problem upgrading python3 with homebrew.

When I run "brew upgrade python3", I get

==> Upgrading 1 outdated package, with result:
python3 3.6.5
==> Processing python3 formula rename to python
==> Unlinking python3
==> Temporarily unlinking python
Error: Error occurred while migrating.
No such file or directory @ realpath_rec - /usr/local/opt/python
Backing up...
Error: No such file or directory @ realpath_rec - /usr/local/opt/python
==> Upgrading python3 
Error: No such file or directory @ realpath_rec - /usr/local/opt/python

Despite failing the upgrade, it has the side-effect of destroying my python3 symlink, so I have to run "brew link python3" afterwards to use it again. This error also screws up brew installs of other packages that depend on python, so it's getting to be pretty bad. Can someone help me fix it?

Edit: I tried "brew uninstall python" and "brew install python" but I get:

~$ brew uninstall python
Warning: Use veclibfort instead of deprecated homebrew/science/veclibfort
Uninstalling /usr/local/Cellar/python/2.7.14... (3,614 files, 50.6MB)
Error: No such file or directory @ realpath_rec - /usr/local/opt/python
~$ brew install python
==> Processing python3 formula rename to python
==> Unlinking python3
==> Temporarily unlinking python
Error: Error occurred while migrating.
No such file or directory @ realpath_rec - /usr/local/opt/python
Backing up...
Error: No such file or directory @ realpath_rec - /usr/local/opt/python
Error: python 2.7.14 is already installed
To upgrade to 3.6.5, run `brew upgrade python`

Upvotes: 2

Views: 5354

Answers (1)

Zgpeace
Zgpeace

Reputation: 4467

I face the issue: Error: Not a directory @ dir_s_rmdir - /usr/local/Cellar/python3.

  1. try to uninstall python3
    $ brew uninstall python3

  2. try to install python
    $ brew install python

  3. try to link the python3

$ brew link [email protected]  
Linking /usr/local/Cellar/[email protected]/3.8.5... 
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
  rm '/usr/local/bin/2to3'

To force the link and overwrite all conflicting files:
  brew link --overwrite [email protected]

To list all files that would be deleted:
  brew link --overwrite --dry-run [email protected]

  1. follow up the tips, remove 2to3
    $ rm '/usr/local/bin/2to3'

  2. link [email protected]
    $ brew link --overwrite [email protected]

fix the error

Upvotes: 1

Related Questions