首页 > 解决方案 > 使用 pytorch 时出现 DLL 文件错误

问题描述

我通过 pip 安装添加 pytorch,现在我正在尝试使用它,但是有这个 dll 错误:

Traceback (most recent call last):
  File "F:/Python/Projects/1.py", line 2, in <module>
    import torch
  File "C:\Users\Saeed\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\__init__.py", line 78, in <module>
    from torch._C import *
ImportError: DLL load failed: The specified module could not be found.

我安装了 msvcp71 和 msvcr71 dll 文件,但它不起作用!

标签: pythondllpippytorch

解决方案


You can use Dependency Walker to find out which dependency of that DLL might be missing. Use it to open the Python extension file that's failing to load. The file name should be something like:

C:\Users\Saeed\AppData\Local\Programs\Python\Python36\lib\site-packages\torch\_C.pyd

Another common cause is a DLL for Python 64-bit while using Python 32-bit or vice-versa. But you installed with pip so it should be OK. Nevertheless, it's a good idea to verify this is not the case.


推荐阅读