Last active
May 30, 2025 16:43
-
-
Save nick-beer/142ab6673a1e96ca09b3308cda25a347 to your computer and use it in GitHub Desktop.
Install Python Environment - Windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires -RunAsAdministrator | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory = $false)] | |
[string] | |
$PythonVersion = '3.11.9' | |
) | |
function Update-Environment { | |
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") | |
} | |
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine | |
# install pyenv-win | |
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" | |
Update-Environment | |
pyenv install $PythonVersion | |
pyenv global $PythonVersion | |
Update-Environment | |
python -m pip install --upgrade pip | |
python -m pip install --user pipx | |
$scriptsDir = & python -c "import os,sysconfig;print(sysconfig.get_path('scripts',f'{os.name}_user'))" | |
& (Join-Path $scriptsDir pipx.exe) ensurepath | |
Update-Environment | |
pipx install poetry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment