How to Install and Use Pyenv
Date: 2023/02/27Last Updated: 2024-03-07T20:23:34.701Z
Categories: Tutorial
Tags: Python, Tutorial, Open Source, pyenv
Read Time: 1 minutes
Contents
Pyenv
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
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