(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 1. 加载模块加载器
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy Bypass -Scope Process -Force
(rtx5070_env) PS E:\PyTorch_Build\pytorch> .\module_loader.ps1
Import-Module: E:\PyTorch_Build\pytorch\module_loader.ps1:72
Line |
72 | Import-Module PyEnvManager -Force
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The specified module 'PyEnvManager' was not loaded because no valid module file was found in any module
| directory.
Set-PythonEnv: C:\Users\Administrator\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:5
Line |
5 | Set-PythonEnv -EnvName global
| ~~~~~~~~~~~~~
| The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
| Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
✅ 环境管理模块已加载
Get-Command: E:\PyTorch_Build\pytorch\module_loader.ps1:98
Line |
98 | Get-Command Set-PythonEnv, New-EnvCheckpoint, Get-EnvGuardStatus |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
| Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Get-Command: E:\PyTorch_Build\pytorch\module_loader.ps1:98
Line |
98 | Get-Command Set-PythonEnv, New-EnvCheckpoint, Get-EnvGuardStatus |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'New-EnvCheckpoint' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
| again.
Get-Command: E:\PyTorch_Build\pytorch\module_loader.ps1:98
Line |
98 | Get-Command Set-PythonEnv, New-EnvCheckpoint, Get-EnvGuardStatus |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'Get-EnvGuardStatus' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
| again.
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 2. 修复环境
(rtx5070_env) PS E:\PyTorch_Build\pytorch> .\env_repair_toolkit.ps1 -ForceReinstall
Import-Module: E:\PyTorch_Build\pytorch\module_loader.ps1:72
Line |
72 | Import-Module PyEnvManager -Force
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The specified module 'PyEnvManager' was not loaded because no valid module file was found in any module
| directory.
Set-PythonEnv: C:\Users\Administrator\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:5
Line |
5 | Set-PythonEnv -EnvName global
| ~~~~~~~~~~~~~
| The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
| Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
✅ 环境管理模块已加载
Get-Command: E:\PyTorch_Build\pytorch\module_loader.ps1:98
Line |
98 | Get-Command Set-PythonEnv, New-EnvCheckpoint, Get-EnvGuardStatus |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
| Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Get-Command: E:\PyTorch_Build\pytorch\module_loader.ps1:98
Line |
98 | Get-Command Set-PythonEnv, New-EnvCheckpoint, Get-EnvGuardStatus |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'New-EnvCheckpoint' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
| again.
Get-Command: E:\PyTorch_Build\pytorch\module_loader.ps1:98
Line |
98 | Get-Command Set-PythonEnv, New-EnvCheckpoint, Get-EnvGuardStatus |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The term 'Get-EnvGuardStatus' is not recognized as a name of a cmdlet, function, script file, or executable
| program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
| again.
WARNING: 创建检查点失败: The term 'New-EnvCheckpoint' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
⚠️ 环境未正确激活
Set-PythonEnv: E:\PyTorch_Build\pytorch\env_repair_toolkit.ps1:44
Line |
44 | Set-PythonEnv -EnvName pytorch
| ~~~~~~~~~~~~~
| The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
| Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
❌ PyTorch未安装: Traceback (most recent call last): File "<string>", line 1, in <module> File "E:\PyTorch_Build\pytorch\torch\__init__.py", line 35, in <module> from typing_extensions import ParamSpec as _ParamSpec, TypeIs as _TypeIs ModuleNotFoundError: No module named 'typing_extensions'
请运行编译安装脚本
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
5 EnvGuard BackgroundJob Running True localhost …
✅ 环境守护进程已启动
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 3. 验证环境状态
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Get-EnvGuardStatus
Get-EnvGuardStatus: The term 'Get-EnvGuardStatus' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 4. 测试环境切换
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-PythonEnv -EnvName global
Set-PythonEnv: The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-PythonEnv -EnvName pytorch
Set-PythonEnv: The term 'Set-PythonEnv' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 5. 测试检查点创建
(rtx5070_env) PS E:\PyTorch_Build\pytorch> New-EnvCheckpoint
New-EnvCheckpoint: The term 'New-EnvCheckpoint' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 6. 测试PyTorch安装
(rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c "import torch; print(torch.cuda.is_available())"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "E:\PyTorch_Build\pytorch\torch\__init__.py", line 35, in <module>
from typing_extensions import ParamSpec as _ParamSpec, TypeIs as _TypeIs
ModuleNotFoundError: No module named 'typing_extensions'
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证模块加载
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Get-Module -Name PyEnvManager
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 查看可用命令
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Get-Command -Module PyEnvManager
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 检查守护进程状态
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Get-EnvGuardStatus
Get-EnvGuardStatus: The term 'Get-EnvGuardStatus' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 检查环境激活状态
(rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c "import sys; print(f'当前前缀: {sys.prefix}')"
当前前缀: E:\PyTorch_Build\pytorch\rtx5070_env
(rtx5070_env) PS E:\PyTorch_Build\pytorch>
(rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证文件权限
(rtx5070_env) PS E:\PyTorch_Build\pytorch> Get-Acl "E:\PyTorchBuild_Secure\rtx5070_env\Scripts\python.exe" |
>> Format-Table Owner, AccessToString -Wrap
Owner AccessToString
----- --------------
BF-202503252000\Administrator BF-202503252000\Administrator Allow FullControl
BF-202503252000\Administrator Allow FullControl
BUILTIN\Administrators Allow FullControl
NT AUTHORITY\SYSTEM Allow FullControl
NT AUTHORITY\Authenticated Users Allow Modify, Synchronize
BUILTIN\Users Allow ReadAndExecute, Synchronize
(rtx5070_env) PS E:\PyTorch_Build\pytorch>