【问题标题】:Accidentally used homebrew to change my default python to 3.7, how do I change it back to 2.7?不小心使用 homebrew 将我的默认 python 更改为 3.7,如何将其更改回 2.7?
【发布时间】:2019-03-31 02:36:13
【问题描述】:

我正在尝试安装 python 3,因为我想使用 python 3 进行项目。我发现的说明不起作用,所以我大胆地运行 brew install python。错误的举动。现在,当我运行 python -V 时,我得到“Python 3.7.3”,当我尝试输入 virtualenv 时,我得到 -bash: /Users/elliot/Library/Python/2.7/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

我的~/.bash_profile 读作 export PATH="/Users/elliot/Library/Python/2.7/bin:/usr/local/opt/python/libexec/bin:/Library/PostgreSQL/10/bin:$PATH"

但是ls /usr/local/Cellar/python/ 得到了我3.7.3 所以看来brew 甚至不知道我的旧2.7 版本了。

我想我想要的是将我的系统 python 重置为 2.7,然后将 python 3 添加为在我的系统上运行的单独 python。我一直在谷歌搜索,但没有找到任何关于如何专门使用 brew 来执行此操作的建议。

编辑:如果我知道如何让 virtualenv 再次工作,我也会很高兴保留 Python 3.7。我记得听说升级你的系统 python 会破坏一切,但我很高兴知道这是否是过时的知识,我只是一个坚持 2.7 的 luddite。

【问题讨论】:

  • 看起来 hombrew 想帮您一个忙... ;)
  • 是的,我知道,我还在 2.7 上做什么?答案是试图不处理此时的升级。如果更新我的路径更简单,以便 virtualenv 知道如何再次运行,我也会对这个解决方案感到满意。

标签: python python-3.x python-2.7 homebrew


【解决方案1】:

所以,我通过完全卸载 Python 来解决这个问题,我一直不愿意这样做,然后重新安装 Python 2。我必须更新我的路径并打开一个新的 shell 才能看到新的 python 2 安装,事情就到位了。我现在在我的 Python 3 项目中使用 pyenv,这是一个梦想。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-26
    • 1970-01-01
    • 1970-01-01
    • 2013-04-09
    • 1970-01-01
    • 2014-11-09
    • 2021-12-31
    相关资源
    最近更新 更多