在Mac上安装Python3.6和Python3.7

问题描述 投票:31回答:2

我正在尝试使用Python3.7将tensorflow安装到Mac上。但是,我收到错误:

$ pip3 -v install tensorflow
...    
    Skipping link https://files.pythonhosted.org/packages/56/7a/c6bca0fe52a94ca508731d8b139e7dbd5a36cddc64c19f422f97e5a853e8/tensorflow-1.10.0rc1-cp36-cp36m-win_amd64.whl#sha256=3ab24374888d6a13d55ce2e3cf4ba0c9cd6f824723313db5322512087525cb78 (from https://pypi.org/simple/tensorflow/); it is not compatible with this Python
  Could not find a version that satisfies the requirement tensorflow (from versions: )
Cleaning up...
Removed build tracker '/private/var/folders/4n/9342s4wd3jv0qzwjz8rxrygr0000gp/T/pip-req-tracker-3p60r2lo'

No matching distribution found for tensorflow

从我可以收集到的这种情况正在发生,因为tensorflow还不支持Python3.7。作为一种解决方法,我想在3.7和3.7之间安装Python3.6,然后将tensorflow安装到该版本。但是,我是Mac的新手,并且不确定正确的方法来做到这一点,而不会有可能搞乱已有的Python版本。

我已经尝试过使用brew,但它看起来像Python3一样具体。做我正在做的事情的正确方法是什么?

macos tensorflow python-3.6 python-3.7
2个回答
93
投票

如果已经使用Python 3,请尝试使用brew

$ brew unlink python

然后install python 3.6.5

$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb

要回到python 3.7.0使用:

$ brew switch python 3.7.0

如果需要3.6再次切换:

$ brew switch python 3.6.5_1
© www.soinside.com 2019 - 2024. All rights reserved.