Last active
March 18, 2025 13:02
-
-
Save dmnc-net/6fdb26204449a1e8ea5767c4520879c1 to your computer and use it in GitHub Desktop.
Windows Python dev environment
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
# Check if the script is running with administrative privileges | |
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
Write-Output "Script is not running as Administrator. Attempting to restart with elevated privileges..." | |
# Relaunch the script with the RunAs verb to prompt for elevation | |
Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs | |
exit | |
} | |
# Install PowerShell 7 | |
Write-Output "Installing PowerShell 7..." | |
winget install --id Microsoft.PowerShell --exact --source winget | |
# Install Windows Terminal | |
Write-Output "Installing Windows Terminal..." | |
winget install --id Microsoft.WindowsTerminal --exact --source winget | |
# Install Visual Studio Code | |
Write-Output "Installing Visual Studio Code..." | |
winget install --id Microsoft.VisualStudioCode --exact --source winget | |
# Install Python | |
Write-Output "Installing Python..." | |
winget install --id Python.Python.3 --exact --source winget | |
# Enable Win32 long paths (for Python) | |
Write-Output "Enabling Win32 long paths..." | |
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name LongPathsEnabled -Value 1 | |
# Install VS Code Python extension | |
Write-Output "Installing the VS Code Python extension..." | |
code --install-extension ms-python.python | |
Write-Output "Installation complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because the system can block downloaded scripts, it is better to create an empty file and copy the content.
Unblock-File -Path .\install-dev-tools.ps1
powershell -ExecutionPolicy Bypass -File .\install-dev-tools.ps1
(orpwsh
instead ofpowershell
)