You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

导入PyTorch时触发OSError错误的问题排查及解决

PyTorch导入报错WinError 126:shm.dll依赖找不到的解决办法

问题现象

导入PyTorch时抛出如下错误,且确认shm.dll文件确实存在于报错提示的路径中:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\torch\__init__.py", line 141, in <module>
    raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\torch\lib\shm.dll" or one of its dependencies.

已尝试的无效方案

  • 检查并确认shm.dll文件存在于指定路径
  • 执行pip3 install torch torchvision torchaudio重新安装PyTorch及其关联库

可行解决方案

将\AppData\Roaming\Python\Library\bin(替换为对应用户目录的完整路径)添加到系统PATH环境变量中,重启终端或开发环境后,PyTorch即可正常导入。

内容的提问来源于stack exchange,提问作者user23247397

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 06:00:55