pyenv
**Pyenv: Simple Python Version Management**
**Overview**
Pyenv is a tool for managing multiple Python versions on a single machine. It allows you to switch between Python 3.8, 3.10, and 2.7 instantly without messing up your system Python.
**The Problem**
- OS X / Linux comes with a System Python (used by the OS). **Never touch this.**
- Project A needs Python 3.7.
- Project B needs Python 3.11.
**How Pyenv works**
It inserts "shims" (executable scripts) into your `$PATH`. When you type `python`, the shim intercepts the command and routes it to the correct version based on your current directory.
**Common Commands**
```bash
# List available versions to install
pyenv install --list
# Install a version
pyenv install 3.10.4
# Set Global version (default)
pyenv global 3.10.4
# Set Local version (for current folder)
cd my_project
pyenv local 3.9.0
# (Creates a .python-version file)
```
**pyenv-virtualenv**
A plugin that manages virtual environments inside pyenv.
```bash
pyenv virtualenv 3.10.4 my-env
pyenv activate my-env
```
**Best Practice**
Use **Pyenv** to manage the Python versions (3.9, 3.10).
Use **Poetry** or **Venv** to manage the libraries (pandas, numpy) inside that version.