Skip to content

Instantly share code, notes, and snippets.

@alexolinux
Created June 6, 2024 09:51
Show Gist options
  • Save alexolinux/35280c20051e918a8ff62d6d57c8c692 to your computer and use it in GitHub Desktop.
Save alexolinux/35280c20051e918a8ff62d6d57c8c692 to your computer and use it in GitHub Desktop.
Managing Python with PyEnv

PyEnv


Manage python versions

List Available Python Versions

pyenv install --list

Install a Specific Python Version

pyenv install 3.9.6

Set a Global Python Version

You can set a global Python version to be used in all shells by running

pyenv global <python_version>
pyenv global 3.9.6

Set a Local Python Version

You can set a local Python version for a specific directory by running

pyenv local <python_version>
pyenv local 3.9.6

List Installed Python Versions

pyenv versions

Use a Specific Python Version

Once you have installed multiple Python versions, you can switch between them using: pyenv global, pyenv local, or pyenv shell commands

pyenv global <python_version>   #sets the global Python version.
pyenv local <python_version>    #sets the local Python version for a specific directory.
pyenv shell <python_version>    #sets the Python version for the current shell session

Manage virtualenvs

Create a Pyenv Virtual Environment

pyenv virtualenv <python_version> <virtualenv_name>
pyenv virtualenv 3.12.0 myenv

List Pyenv Virtual Environments

pyenv virtualenvs

Activate a Pyenv Virtual Environment

pyenv activate myenv

Deactivate a Pyenv Virtual Environment

pyenv deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment