HomeBrew捣乱了Python安装

3

之前,我有这个:

$ python # version 2.7.x
$ python3 # version 3.6.x

这个本来是正常工作的。我愚蠢地试图修复一些没有问题的东西,然后运行了以下命令:

brew install python@2
brew install python@3

我认为这样做可以实现以下目的:
$ python2 # version 2.7.x
$ python3 # version 3.6.x

但实际上它所做的是:
$ python2 # doesn't exist, damnit
$ python # version 3.6.x

我期望得到的最终结果:

$ python # version 2.7.x
$ python2 # version 2.7.x
$ python3 # version 3.6.x

实际上,如果可能的话,在版本2/3之间切换$python会很好。我如何在MacOS上做到这一点?

2个回答

0

我刚刚做了

brew uninstall python@2
brew uninstall python@3

然后重新运行

brew install python@3

现在:

 python --version # => 2.7.x

并且

python3 --version # => 3.6.x

0

Python 2.7 是 Mac OS 的默认程序,不应该被删除。您可以通过创建别名来将 python3 设置为默认程序 - 打开 ~/.bash_profile 文件并添加 alias python='python3'

下次当您输入 python 时,将会选择 python3 而不是 python 2.7。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接