Published , Last updated
Managing multiple Python versions on Windows can be a challenge especially when you're switching between projects that require different environments. That’s where pyenv-win comes in.
In this guide, you’ll learn how to install pyenv-win
using PowerShell, install Python versions, switch between them, and validate everything step by step. Ideal for Python developers looking to keep their workflow clean and organized on Windows.
pyenv-win is a Python version management tool for Windows. It allows you to:
It’s the Windows counterpart of the popular UNIX tool pyenv
.
Right-click the Start Menu → Select Windows PowerShell (Admin).
Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"
This downloads and installs pyenv-win to your user directory.
Close and reopen PowerShell so that environment variables take effect.
pyenv --version
You should see the installed version of pyenv-win, confirming successful setup.
pyenv install -l
pyenv install 3.13.3
pyenv global 3.13.3
cd D:\Projects\MyApp pyenv local 3.10.9
pyenv version
Output:
3.13.3 (set by C:\Users\YourName\.pyenv\pyenv-win\.python-version)
To see the actual Python path being used:
python -c "import sys; print(sys.executable)"
Example:
C:\Users\YourName\.pyenv\pyenv-win\versions\3.13.3\python.exe
Command | Description | Example |
---|---|---|
pyenv install -l | List all installable Python versions | pyenv install -l |
pyenv install <version> | Install a specific Python version | pyenv install 3.9.13 |
pyenv global <version> | Set system-wide Python version | pyenv global 3.10.9 |
pyenv local <version> | Set Python version for current directory | pyenv local 3.9.13 |
pyenv shell <version> | Set Python version for current session | pyenv shell 3.11.2 |
pyenv uninstall <version> | Remove an installed version | pyenv uninstall 3.13.3 |
pyenv versions | List all installed versions | pyenv versions |
pyenv which python | Get the full path to active Python | pyenv which python |
cd D:\Code\ProjectA
pyenv local 3.9.13
cd D:\Code\ProjectB
pyenv local 3.11.2
Each project now runs with its correct Python version.
pyenv uninstall 3.13.3
pyenv local
for project-specific environments.python-version
in version controlpython -c "import sys; print(sys.executable)"
to confirm Python path
When running the install script, you might see this error:
Error: Running scripts is disabled on this system.
In PowerShell (Admin), run the following command:
Set-ExecutionPolicy RemoteSigned
Y
and press Enter when prompted.
Problem | Fix |
---|---|
pyenv not recognized | Restart terminal or check environment variables |
Python version doesn’t switch | Run pyenv rehash or reopen PowerShell |
With pyenv-win, managing Python on Windows becomes as easy as on UNIX systems. Install multiple versions, switch between them effortlessly, and keep your projects isolated and organized.