-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_python_path.ps1
More file actions
16 lines (14 loc) · 828 Bytes
/
Copy pathfix_python_path.ps1
File metadata and controls
16 lines (14 loc) · 828 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$pythonPath = "C:\Python\Python311"
$scriptsPath = "$pythonPath\Scripts"
# Get current user path
$currentPath = [Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
# Check if paths are already included
if ($currentPath -like "*$pythonPath*" -and $currentPath -like "*$scriptsPath*") {
Write-Host "Python paths are already in your User PATH." -ForegroundColor Green
} else {
# Append paths
$newPath = $currentPath + ";" + $pythonPath + ";" + $scriptsPath
[Environment]::SetEnvironmentVariable("Path", $newPath, [EnvironmentVariableTarget]::User)
Write-Host "Success! Added $pythonPath and $scriptsPath to your User PATH." -ForegroundColor Green
Write-Host "IMPORTANT: Please restart your terminal/PowerShell window for the changes to take effect." -ForegroundColor Yellow
}