$ python -bash: /usr/local/bin/python: 没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46179672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
$ python -bash: /usr/local/bin/python: No such file or directory
提问by codyc4321
Python is broken somehow after running a script that rewrites files. I get the error anytime I use it:
运行重写文件的脚本后,Python 以某种方式损坏。我每次使用它时都会收到错误消息:
$ 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?
我该如何修复这个 Python?
采纳答案by codyc4321
I've got no idea what happened here, but I tried reinstalling yesterday...reinstalling this way (seemingly what I already did) today worked:
我不知道这里发生了什么,但我昨天尝试重新安装……以这种方式重新安装(似乎我已经这样做了)今天有效:
回答by tresf
Something seems to go haywire with Homebrew 1.7.2 and MacOS 10.13.6.
Homebrew 1.7.2 和 MacOS 10.13.6 似乎有些出问题了。
Even after removing all python versions and reinstalling, python --version
simply won't work.
即使在删除所有 python 版本并重新安装后,也python --version
根本无法工作。
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