12

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 <brew-test-bot@googlegroups.com>
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?

Leon
  • 123
  • 1
  • 1
  • 4
  • I'm voting to close this question as off-topic because this belongs to http://apple.stackexchange.com/ – frlan Jan 08 '17 at 09:41

2 Answers2

10

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

Adrian W
  • 4,563
  • 11
  • 38
  • 52
user2495402
  • 124
  • 1
  • 3
7
$ 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.

Community
  • 1
  • 1
McGrady
  • 10,869
  • 13
  • 47
  • 69
  • brew switch doesn't seem to work despite the cellar having a previous version directory ```~ admin$ brew switch python 3.8.6_1 Error: python does not have a version "3.8.6_1" in the Cellar. python's installed versions: 3.9.0_1 ~ admin$ ~ admin$ ls -la /usr/local/Cellar/python\@3.8/3.8.6_1/ total 64 ``` – wesinat0r Dec 09 '20 at 19:55
  • This worked for me: (run under admin user) `brew link --overwrite python@3.8` . With Python 3.9 installed, this changes python3 command back to python3.8 – wesinat0r Dec 09 '20 at 22:15