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

Python

Introduction

Prerequisites

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

Step 1 — Getting Started

curl https://pyenv.run | 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 https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

Step 2 — List installed python versions

pyenv versions

Step 3—Other useful pyenv commands:

which

$ pyenv which pip
/home/realpython/.pyenv/versions/3.6.8/bin/pip

global

$ pyenv global 3.6.8

local

$ pyenv local 2.7.15

shell

$ pyenv shell 3.8-dev

Conclusion

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