简体   繁体   中英

How to use Homebrew to upgrade to a specific Python version?

I've been using Homebrew to install various packages on my 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. At first, I just tried upgrading to 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.

I then tried to search to see what versions of Python brew has available:

brew search python

Now Homebrew tells me, "If you meant "python" specifically: It was migrated from caskroom/cask to 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. 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?

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. The github repo has a very detailed and clear guide on usage: https://github.com/pyenv/pyenv

To see the version of python use python --version, and for upgrade use sudo apt-get upgrade python. I used this, and it's worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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