Windows PowerShell
版权所有(C) Microsoft Corporation。保留所有权利。
安装最新的 PowerShell,了解新功能和改进!https://aka.ms/PSWindows
PS C:\WINDOWS\system32> uv --version
uv : 无法将“uv”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然
后再试一次。
所在位置 行:1 字符: 1
+ uv --version
+ ~~
+ CategoryInfo : ObjectNotFound: (uv:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\WINDOWS\system32> powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
downloading uv 0.11.21 (x86_64-pc-windows-msvc)
installing to C:\Users\gao\.local\bin
uv.exe
uvx.exe
uvw.exe
everything's installed!
To add C:\Users\gao\.local\bin to your PATH, either restart your shell or run:
set Path=C:\Users\gao\.local\bin;%Path% (cmd)
$env:Path = "C:\Users\gao\.local\bin;$env:Path" (powershell)
PS C:\WINDOWS\system32>
1. 重新加载 Path 环境变量
Path 是最常见需要修改的环境变量。当我们添加新的路径到 Path 后,通常需要让 PowerShell 立即识别这些新的路径,而不是依赖重新启动系统或 PowerShell 会话。
使用以下命令可以重新加载 Path 环境变量:
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) + ";" + [System.Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User)