How to Install and Use Pyenv
Date: 2023/02/27Last Updated: 2023-11-03T21:47:00.000Z
Categories: Tutorial
Tags: Python, Tutorial, Open Source, pyenv
Read Time: 1 minutes
0.1 Contents
0.2 Pyenv
0.2.1 Install the pyenv
brew install pyenv-virtualenv
Add the following line to .zshrc or .zprofile to run pyenv
# python env auto activation
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi
To run pyenv in the current session, run
source ~/.zshrc
Install python version List all available python version
pyenv install βlist
Install a specific version
pyenv install $VERSION
List all installed versions
P
0.2.2 Change versions
Set the global python version for the system
pyenv global $VERSION
Set local version
pyenv local $VERSION
Create a specific virtualenv for repo
pyenv virtualenv $PYTHON_VERSION $NAME
Use virtualenv for repo
pyenv local $NAME