brew update
brew install pyenv
Add the following line to ~/.bash_profile
(or ~/.zshrc
):
eval "$(pyenv init -)"
brew install pyenv-virtualenvwrapper
pyenv virtualenvwrapper
Add the following to ~/.bash_profile
(or ~/.zshrc
):
export PYENV_VIRTUALENVWRAPPER_PREFER_PYVENV="true"
Restart your shell or source your profile:
source ~/.bash_profile
or
source ~/.zshrc
List available Python versions you can install:
pyenv install --list
Install a Python version
pyenv install 3.7.6
pyenv install 3.8.1
See what Python versions you have installed:
pyenv versions
Switch Python versions globally or locally:
pyenv global 3.7.6
pyenv local 3.8.1
Creating a local version for a project should create a .python-version
file with the project version (this should be checked in)
Create a virtualenv:
mkvirtualenv my-venv
Install a package with pip:
pip install ipython
Capture dependancies in git:
pip freeze > requirements.txt
git add requirements.txt