Pyenv Activation Skill
This skill should be used when activating pyenv virtual environments or troubleshooting pyenv activation issues.
Purpose
Activate pyenv virtual environments reliably, with fallbacks when standard activation methods fail.
Activation Methods
Method 1: Standard Activation (Preferred)
pyenv activate <env-name>
This requires pyenv-virtualenv to be loaded into the shell.
Method 2: Shell Re-initialization
If pyenv-virtualenv is not loaded:
eval "$(pyenv init -)" && eval "$(pyenv virtualenv-init -)" && pyenv activate <env-name>
Method 3: Direct Virtual Environment Activation
When pyenv activation fails or shell integration is not enabled, activate the virtual environment directly using its path:
source /Users/alexismanuel/.pyenv/versions/<python-version>/envs/<env-name>/bin/activate
To find the correct path:
- Run
pyenv versionsto list available environments - Note the Python version and environment name
- Construct the path:
~/.pyenv/versions/<version>/envs/<env-name>/bin/activate
Troubleshooting
| Error | Cause | Solution |
|-------|-------|----------|
| "pyenv-virtualenv has not been loaded" | pyenv-virtualenv plugin not initialized | Use Method 2 |
| "shell integration not enabled" | pyenv shell integration not configured | Use Method 3 |
| Activation appears to work but wrong Python version | Environment not properly activated | Verify with python --version and which python |
Verification
After activation, always verify the environment is active:
python --version
which python
Expected output should show the Python version from the pyenv environment and a path under ~/.pyenv/versions/.