How to Manage Multiple Python Versions in MacOS. (2021 Guide)




brew install openssl readline sqlite3 xz zlib
nano ~/.zshrc

Step 1 — Getting Started

curl | bash
exec $SHELL # Or just restart your terminal
pyenv -v

Step 2— Install python versions

pyenv install --lis
pyenv install --list | grep " 3\.[678]"
pyenv install 3.7.3
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.8.0 < <(curl -sSL\?full_index\=1)

Step 2 — List installed python versions

pyenv versions

Step 3—Other useful pyenv commands:


$ pyenv which pip


$ pyenv global 3.6.8


$ pyenv local 2.7.15


$ pyenv shell 3.8-dev


How to Manage Multiple Java Versions in MacOS

How to Manage Multiple Node Versions in MacOS

Versatile Full-stack Developer with 5+ years of experience designing, developing, and managing complex applications and internal frameworks.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store