Python Version Management with pyenv
Check Python Version
To display the current Python version (e.g., Python 3.12.2 or the version set with pyenv):
List Installed Versions
To list all installed Python versions and see which one is active (marked with *):
Check Active Python Environment
To check which Python environment is currently active:
Create a Python Virtual Environment
To create a new Python virtual environment (e.g., virLanggraphEnv using Python 3.12.2):
Activate a Python Environment
To activate a specific Python environment (e.g., virLanggraphEnv):
Set a Local Python Environment (.python-version)
- The
pyenv localcommand sets a directory-specific Python version by creating a.python-versionfile in the current directory. - This ensures automatic activation of the specified Python environment whenever the directory is accessed.
- To set a specific Python environment as the local version (e.g.,
virLanggraphEnv):
Uninstall a Python Environment
To uninstall a specific Python environment (e.g., virLanggraphEnv):
1. Use pyenv virtualenv-delete if you want to be explicit that you're deleting a virtualenv
2. Use pyenv uninstall as the universal command for removing anything pyenv manages
Locate Python and Pip
Check the Shim
The shim is a pointer to the actual pip or python binary, depending on the currently activated Python environment:
Find the Actual Path
To display the actual path to the current Python binary (not just the shim):
Example Workflow
Activate the environment and verify the pip path: