7 Days0Site 7 Days0
30 Days0Site 30 Days0
Total0Site Total0

How to Install and Use Pyenv

Date: 2023/02/27
Last Updated: 2024-08-16T15:42:43.994Z
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