PyEnv-Win
Quick Commands
Command | Description |
---|---|
SHELL Copied!
|
Show all available Python versions to install |
SHELL Copied!
|
Install a specific Python version |
SHELL Copied!
|
Remove an installed version |
SHELL Copied!
|
List installed versions |
SHELL Copied!
|
List current running version |
SHELL Copied!
|
Set global (default) Python version |
SHELL Copied!
|
Set local Python version (per project directory) |
SHELL Copied!
|
Temporarily set Python version for the shell |
SHELL Copied!
|
Rebuild pyenv shims (usually automatic) |
SHELL Copied!
|
Show full path to the selected Python binary |
Top ↑ |
How to Install PyEnv on Windows
-
Download pyenv-win ZIP-archive: pyenv-win
-
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
-
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.
-
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")
-
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")
-
Open PowerShell as an administrator, press
Windows + R
, type 'powershell', then pressCtrl + Shift + Enter
to launch it with administrative privileges. -
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
-
Now, you can run pyenv by entering.
POWERSHELL
Copied!
pyenv
-
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 ↑ |