Last active
March 20, 2022 10:33
-
-
Save 18520339/c3bb7ab557d89141c5ce873317ddffab to your computer and use it in GitHub Desktop.
Install Python amd64 via Windows Powershell
This file contains 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
# Ask for administrator privilege | |
if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | |
Start-Process PowerShell -Verb RunAs "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`""; | |
exit; | |
} | |
# Check if Python exists before installation | |
if(&{python -V} 2>&1 -is [System.Management.Automation.ErrorRecord]) { | |
$TEMP_DIR = [System.IO.Path]::GetTempPath() | |
$PYTHON_VERSION = "3.8.10" # Specify Python version from https://www.python.org/downloads/windows | |
$SAVED_NAME = "python-$PYTHON_VERSION-amd64.exe" | |
$DOWNLOAD_URL = "https://www.python.org/ftp/python/$PYTHON_VERSION/$SAVED_NAME" | |
bitsadmin.exe /transfer "Download Python $PYTHON_VERSION" $DOWNLOAD_URL $TEMP_DIR$SAVED_NAME | |
cd $TEMP_DIR | |
Invoke-Expression ".\$SAVED_NAME /quiet InstallAllUsers=0 PrependPath=1 Include_test=0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment