DEV Community

0xkoji
0xkoji

Posted on

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

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

Top comments (3)

Collapse
 
punkrockpolly profile image
Polina Giralt

Adding a note that this also worked for 3.6.8 Thank you!

Collapse
 
melika_adabinejad profile image
melika adabinejad

Thank you! this worked for 3.6.8 for Macbook with M2 and Mac OS Sonoma 14.2

Collapse
 
bubuybawang profile image
bubuybawang

just dropping by to say that this guide helped with the "BUILD FAILED (OS X 11.6 using python-build 20180424)" issues i'm having when installing 3.6.5