codyc4321
codyc4321

Reputation: 9672

$ python -bash: /usr/local/bin/python: No such file or directory

Python is broken somehow after running a script that rewrites files. I get the error anytime I use it:

$ python
-bash: /usr/local/bin/python: No such file or directory

I did brew doctor:

$ brew unlink python && brew link python

Yesterday I tried to fix it by reinstalling:

$ brew update
$ brew install python
$ brew upgrade python

Based on what I found it seems like I need to symlink it but I don't want to make it worse and lose the entire OS.

$ which python
/usr/bin/python

How can I fix this Python?

Upvotes: 16

Views: 47566

Answers (2)

tresf
tresf

Reputation: 7922

Something seems to go haywire with Homebrew 1.7.2 and MacOS 10.13.6.

Even after removing all python versions and reinstalling, python --version simply won't work.

Most have probably already tried these steps...

brew uninstall --ignore-dependencies python
brew uninstall --ignore-dependencies python2
brew uninstall --ignore-dependencies python3
brew install python
brew unlink python && brew link python
brew unlink python3 && brew link python3

At the end what worked for me was...

sudo ln -s /usr/local/bin/python3 /usr/local/bin/python

And then again for pip...

sudo ln -s /usr/local/bin/pip3 /usr/local/bin/pip

Upvotes: 31

codyc4321
codyc4321

Reputation: 9672

I've got no idea what happened here, but I tried reinstalling yesterday...reinstalling this way (seemingly what I already did) today worked:

How to fix broken python 2.7.11 after OSx updates

Upvotes: 2

Related Questions