PyEnv-Win


Quick Commands

Command Description

SHELL

Copied!


pyenv install --list
Show all available Python versions to install

SHELL

Copied!


pyenv install 3.12.1
Install a specific Python version

SHELL

Copied!


pyenv uninstall 3.12.1
Remove an installed version

SHELL

Copied!


pyenv versions
List installed versions

SHELL

Copied!


pyenv --version
List current running version

SHELL

Copied!


pyenv global 3.12.1
Set global (default) Python version

SHELL

Copied!


pyenv local 3.12.1
Set local Python version (per project directory)

SHELL

Copied!


pyenv shell 3.12.1
Temporarily set Python version for the shell

SHELL

Copied!


pyenv rehash
Rebuild pyenv shims (usually automatic)

SHELL

Copied!


pyenv which python
Show full path to the selected Python binary
Top ↑

How to Install PyEnv on Windows

  1. Download pyenv-win ZIP-archive: pyenv-win

  2. Create a new folder .pyenv in your user folder with the name .pyenv. You can do this using the Explorer or the following PowerShell command:

    POWERSHELL

    Copied!

    
    mkdir $HOME/.pyenv
  3. Extract the ZIP-archive and copy the pyenv-win folder and the .version file from the pyenv-win-master folder into the newly created .pyenv folder in your user folder.

  4. Set the environment variables PYENV and PYENV_HOME that point to the installation folder.

    POWERSHELL

    Copied!

    
    [System.Environment]::SetEnvironmentVariable('PYENV',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
    [System.Environment]::SetEnvironmentVariable('PYENV_HOME',$env:USERPROFILE + "\.pyenv\pyenv-win\","User")
  5. Add the bin folder to the PATH variable. Such that pyenv can be found when using the command line.

    POWERSHELL

    Copied!

    
    [System.Environment]::SetEnvironmentVariable('path', $env:USERPROFILE + "\.pyenv\pyenv-win\bin;" + $env:USERPROFILE + "\.pyenv\pyenv-win\shims;" + [System.Environment]::GetEnvironmentVariable('path', "User"),"User")
  6. Open PowerShell as an administrator, press Windows + R, type 'powershell', then press Ctrl + Shift + Enter to launch it with administrative privileges.

  7. Enter the following command into the PowerShell to enable the execution of scripts. Press A to choose Yes to ALL. Afterward, you can close this PowerShell window and open a new one without admin privileges.

    POWERSHELL

    Copied!

    
    Set-ExecutionPolicy unrestricted
  8. Now, you can run pyenv by entering.

    POWERSHELL

    Copied!

    
    pyenv
  9. If you encounter a security warning from where you have to choose if you want to run pyenv you can disable this warning by “unblocking” the pyenv script with the following command.

    POWERSHELL

    Copied!

    
    Unblock-File $HOME/.pyenv/pyenv-win/bin/pyenv.ps1
Quick Links
How to Install Multiple Python Versions on your Computer and use them with VSCode
Top ↑