pyenv Cheat Sheet

Posted by Vivek Shukla on Oct 22, 2023 under Python

Here is the pyenv cheat sheet of all the basic commands list.

What is pyenv

pyenv is Python version management tool, it lets you easily switch between multiple versions of Python.

What it does

  • Lets you change the global Python version on a per-user basis.

  • Provides support for per-project Python versions.

  • Allows you to override the Python version with an environment variable.

List available python versions to install

This will list all the available version of python

pyenv install --list

You can filter it using grep. Here we are filtering list by python version:

pyenv install --list | grep " 3.11"

Installing Python Version

pyenv install <version>

add -v flag to see install progress output

List Installed Python Versions

pyenv versions

Astrick (*) indicate current active version.

See List Of All pyenv Commands

pyenv commands

Activating Python Version

global

  • Sets the given version as global python version.

  • It overrides system’s default python version.

pyenv global <version>

local

  • Use it to set directory / project specific python version.

  • It can override python version set by global

pyenv local <version>

shell

  • Sets shell specific python version.

  • The python version stays active until shell has been closed or by using --unset flag.

  • It can override python version set by local and global

pyenv shell <version>

Virtual Environments

Create Virtual Environments

pyenv virtualenv <version> <env_name>

Set virtual environment as default for dir/project

pyenv local <env_name>

Activate Virtual Environment

pyenv activate <env_name>

Deactivate Virtual Environment

pyenv deactivate
Built with  Svelte Starter Kit