7
votes

I installed python3 with homebrew on my Mac. However, the latest Python3.6 cannot work well with some packages, so I decide to roll back to the 3.5.2.

Since homebrew/versions has been deprecated,I checkout the commit in the directory: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula

git log python3.rb

There

commit ec545d45d4512ace3570782283df4ecda6bb0044
Author: BrewTestBot <[email protected]>
Date:   Tue Oct 11 06:42:06 2016 +0100

      python3: update 3.5.2_3 bottle.

Then

git chekcout ec545 
brew install python3

However, it seems that homebrew update itself automatically I run $brew install [Formula]

➜  Formula git:(ec545d4) brew install python3
    Updating Homebrew...

How to not update homebrew automatically when brew install some packages? Or how to install python 3.5.2 with homebrew?

2
I'm voting to close this question as off-topic because this belongs to apple.stackexchange.comfrlan

2 Answers

7
votes

Answer for the first question, How to not update homebrew automatically when brew install some packages?

  1. hack code solution:

    vim /usr/local/Homebrew/Library/Homebrew/brew.sh

    Add return after line

    update-preinstall() {

    to:

    update-preinstall() {
    return
    
  2. environment variable solution:

    export HOMEBREW_NO_AUTO_UPDATE=1

    or

    export HOMEBREW_AUTO_UPDATING=0

    or

    export HOMEBREW_UPDATE_PREINSTALL=0

if U will always work, add it to .bash_profile

6
votes
$ brew tap derekkwok/python or (zoidbergwill/python)
$ brew versions python
$ brew install python35

If you have already installed the older version of the formula you can simply switch the symlinks to reference it using a brew command.

brew switch python 3.5.2

If you want to keep a certain version and stop it from being updated ,you can pin a formula.

brew pin python

Also you can try this Python Version Management pyenv.
brew install pyenv
pyenv install 3.5.2

By the way,you can see homebrew-install-specific-version-of-formula to learn more.