简体   繁体   English

如何使用Homebrew升级到特定的Python版本?

[英]How to use Homebrew to upgrade to a specific Python version?

I've been using Homebrew to install various packages on my Mac. 我一直在使用Homebrew在Mac上安装各种软件包。 Currently I have Python 2.7.13 installed via Homebrew but I'd like to upgrade to Python 3.5.x, not 3.6 which is brew's current default. 目前,我已经通过Homebrew安装了Python 2.7.13,但是我想升级到Python 3.5.x,而不是brew的当前默认设置3.6。 At first, I just tried upgrading to Python 3: 刚开始,我只是尝试升级到Python 3:

brew install python3

Brew said "python 2.7.13 is already installed. To upgrade to 3.6.5, run brew upgrade python " which isn't the version I want. Brew说“ python 2.7.13已经安装。要升级到3.6.5,请运行brew upgrade python ”,这不是我想要的版本。

I then tried to search to see what versions of Python brew has available: 然后,我尝试搜索以查看可用的Python brew版本:

brew search python

Now Homebrew tells me, "If you meant "python" specifically: It was migrated from caskroom/cask to homebrew/core." 现在,Homebrew告诉我:“如果您要专门说“ python”,那就是:它已从酒馆/酒桶迁移到了Homebrew / core。”

I then looked at homebrew-core on Github but it doesn't appear to provide any instructions on how to do what I want to do. 然后,我在Github上查看了homebrew-core,但它似乎没有提供有关如何做我想做的任何指示。 Does anyone know how to now display a list of Python versions that one can install using Homebrew and what command to use to install a specific version? 有谁知道如何现在显示可以使用Homebrew安装的Python版本列表,以及用于安装特定版本的命令?

There are several discussions of this, here and elsewhere. 在这里和其他地方对此都有一些讨论。 There is no direct way to do what you want. 没有直接的方法可以做您想要的。 The recommended approach is to install pyenv via brew, and use pyenv to manage the different versions of Python on your system. 推荐的方法是通过brew安装pyenv,并使用pyenv来管理系统上不同版本的Python。 The github repo has a very detailed and clear guide on usage: https://github.com/pyenv/pyenv github仓库有一个非常详细的使用指南: https : //github.com/pyenv/pyenv

To see the version of python use python --version, and for upgrade use sudo apt-get upgrade python. 要查看python的版本,请使用python --version;要进行升级,请使用sudo apt-get upgrade python。 I used this, and it's worked 我用过的,它起作用了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM