Skip to content

Pyenv-win

Pyenv-win is a Python version management tool for Windows. It is a port of the popular pyenv tool for Unix-like systems. It allows you to easily switch between multiple versions of Python. It is simple, unobtrusive, and follows the UNIX tradition of single-purpose tools that do one thing well.

Install Pyenv-win

To install pyenv-win, open a PowerShell window as an administrator and run the following command:

choco install pyenv-win -y

Add the system environment variables PYENV, PYENV_HOME and PYENV_ROOT to your Environment Variables by running the following commands in PowerShell:

[System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")

[System.Environment]::SetEnvironmentVariable('PYENV_ROOT',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")

[System.Environment]::SetEnvironmentVariable('PYENV_HOME',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")

Then add the paths to USER PATH to be able to use the commands. In PowerShell, run the following command:

[System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")

To enable pyenv-win to run scripts in PowerShell, run the following command:

Set-ExecutionPolicy RemoteSigned

If you cant set the Execution Policy by running PowerShell as Administrator, you can set it under the current user scope by running the following command:[^1]

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser