Pyenv
Pyenv is a simple and efficient Python version manager. It allows you to easily install, switch, and uninstall different Python versions for your projects. This ensures that you always have the correct Python version for each project, preventing conflicts and ensuring compatibility.
Installation
Instructions for installing Pyenv can be found on the official GitHub repository.
Basic Usage
---
syntax: bash
tags: [ python, environments ]
---
# Install the specified version of Python:
pyenv install <version>
# Set the specified version of Python as system's default:
pyenv global <version>
# Set the specified version of Python to be used in the current directory:
pyenv local <version>
# Create a virtual environment based on the specified Python version (requires `pyenv-virtualenv` plugin):
pyenv virtualenv <version> <virtualenv_name>
# Activate a python verison or virtualenv in the current shell (requires `pyenv-virtualenv` plugin):
pyenv activate <virtualenv_name>
# Activate a python version or virtualenv in a new shell (requires `pyenv-virtualenv` plugin):
pyenv shell <virtualenv_name>
# Uninstall the specified version of Python:
pyenv uninstall <version>
# List the versions installed:
pyenv versions
# Check the version of python currently in use:
pyenv version
Further Reading
For more advanced usage and troubleshooting, refer to the Pyenv documentation and the Real Python tutorial.