Install python 3.7, 3.6, 3.5, and 3.4 on BigSure with pyenv

0xkoji - Mar 26 '21 - - Dev Community

This post is about installing python 3.5, 3.6, and 3.7 since my previous post only supports python 3.8 and 3.9.
Also, I have gotten some questions on installing python 3.5 and 3.6.

In addition, I really need to install them on my BigSur lol.

If you just need to install python 3.8+, please check the following

precondition

  • Installed Homebrew

install packages with brew

brew install zlib
brew install sqlite
brew install bzip2
brew install libiconv
brew install libzip
Enter fullscreen mode Exit fullscreen mode

Install python 3.4.10

$ LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.4.10 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Enter fullscreen mode Exit fullscreen mode

Install python 3.5.7

$ LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.5.7 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Enter fullscreen mode Exit fullscreen mode

Install python 3.6.5

$ LDFLAGS="-L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.6.5 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Enter fullscreen mode Exit fullscreen mode

I also tried to install 3.6.9 and worked well(just changed the version).

Install python 3.7.3

I tried to install 3.7.6, 3.7.7, 3.7.8, and 3.7.9, but couldn't install them. Only 3.7.3 worked with the following.

$ CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" pyenv install --patch 3.7.3 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
Enter fullscreen mode Exit fullscreen mode
$ pyenv versions
  system
  3.4.10
  3.5.7
  3.6.5
  3.7.3
  3.8.3
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .