Last active
July 7, 2024 20:58
-
-
Save raoshaab/de861c353ab0e0cb77f8afd5325e43c1 to your computer and use it in GitHub Desktop.
Install Python 3 with powershell in windows 10
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
# Download the latest version of Python from the official website | |
$pythonUrl = "https://www.python.org/ftp/python/3.10.0/python-3.10.0-amd64.exe" | |
$pythonInstaller = "$($env:TEMP)\python.exe" | |
Invoke-WebRequest -Uri $pythonUrl -OutFile $pythonInstaller | |
# Install Python with default settings | |
Start-Process -FilePath $pythonInstaller -ArgumentList "/quiet" -Wait | |
# Add Python to the PATH environment variable | |
$pythonPath = Join-Path $env:ProgramFiles "Python310" | |
[System.Environment]::SetEnvironmentVariable("Path", "$($env:Path);$pythonPath", "User") | |
# Verify the installation | |
python --version |
I created my own version based off of your work. Thanks again.
Now Updated !!
You can define the install directory and supply it as new argument TargetDir
,
# Define the target installation directory i.e $installDir = "D:\newfolder\python3"
$installDir = "D:\Python3"
# Install Python with specified installation directory
Start-Process -FilePath $pythonInstaller -ArgumentList "/quiet PrependPath=1 TargetDir=$installDir" -Wait
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks friend. ♥
Small problem 😖
Seems to have worked fine, minus:
My Fix