zsh: /usr/local/bin/youtube-dl: 错误的解释器: /usr/local/opt/python/bin/python2.7: 没有那个文件或目录

zsh: /usr/local/bin/youtube-dl: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory

macOS 10.12

似乎是同一个问题 ,但最热门的答案只会引出更多问题。

说到做到:

brew link --overwrite python

产生:

Warning: Already linked: /usr/local/Cellar/python/3.6.5
To relink: brew unlink python && brew link python

我很确定我需要自制程序才能切换到 2.7 而不是使用版本 3。我确实

brew unlink python && brew link python

并得到:

Unlinking /usr/local/Cellar/python/3.6.5... 25 symlinks removed
Linking /usr/local/Cellar/python/3.6.5... 25 symlinks created

有什么方法可以让它 link 成为特定版本? /usr/local/Cellar/python/ 包含:2.7.13 2.7.14 2.7.14_3 3.6.3 3.6.5

如何让我的系统始终使用 2.7.14_3

/usr/local/opt/python/bin 包含 python3python3-config 和 3.6 版本。我怎样才能在这里得到 2.7 并删除 3 和 3.6?

还有which pythonreturns/usr/bin/python。当我输入 python -V 时,我得到 Python 2.7.10/usr/bin 包含 python2.7python2.7-config 以及其他一些看似与 python 相关的内容(但没有 python3,我认为这很好)。这与自制软件 pythons 有何不同?提前致谢。

编辑:

head -n1 /usr/local/bin/pip returns

head: /usr/local/bin/pip: No such file or directory

mv /usr/local/bin/pip /usr/local/bin/pip.old

returns

mv: rename /usr/local/bin/pip to /usr/local/bin/pip.old: No such file or directory

  1. brew uninstall --ignore-dependencies python(您可能不想 --ignore dependencies 取决于您可能破坏的其他内容,即 numpy、opencv)

  2. brew install python@2 see here

  3. brew uninstall youtube-dl

  4. brew install youtube-dl