修正的方案三:使用符号链接(PowerShell版本)
步骤1:停止Python进程并移动文件
powershell
以管理员身份运行PowerShell
1. 停止所有Python进程
Stop-Process -Name "python" -Force -ErrorAction SilentlyContinue
Stop-Process -Name "pythonw" -Force -ErrorAction SilentlyContinue
2. 创建D盘目录
New-Item -ItemType Directory -Path "D:\Python39" -Force
3. 移动Python文件夹到D盘
Move-Item -Path "C:\Users\admin\AppData\Local\Programs\Python\Python39" -Destination "D:\Python39" -Force
4. 验证移动成功
Test-Path "D:\Python39\Python39\python.exe"
步骤2:创建符号链接
powershell
创建符号链接(需要管理员权限)
New-Item -ItemType SymbolicLink -Path "C:\Users\admin\AppData\Local\Programs\Python\Python39" -Target "D:\Python39\Python39"
或者使用junction(目录连接)
cmd /c "mklink /J "C:\Users\admin\AppData\Local\Programs\Python\Python39" "D:\Python39""
步骤3:验证链接
powershell
验证符号链接
Get-Item "C:\Users\admin\AppData\Local\Programs\Python\Python39" | Format-List
测试Python
& "D:\Python39\python.exe" --version
python --version
查看链接详情
cmd /c dir "C:\Users\admin\AppData\Local\Programs\Python\Python39"