Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

bash

macos

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?

like image 804
codyc4321 Avatar asked Sep 12 '17 14:09

codyc4321


1 Answers

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
like image 162
tresf Avatar answered Oct 21 '22 03:10

tresf