Python Env setup for Mac

Bipul Kuri
Dec 24, 2020

Proper and clean way of Python install on mac

First install pyenv

brew install pyenv

Look at the available python versions

pyenv install --list

and then select a version to install

$pyenv install 3.9.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.9.0.tar.xz...
-> https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz
Installing Python-3.9.0...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.9.0 to /Users/jondoe/.pyenv/versions/3.9.0
$

setup the bash profile

$echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

or zsh

$echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc

--

--