问题现象
运行逻辑:
import torch
报错如下:
traceback (most recent call last):
file "c:\scaffold\metasequoia-tyc\ner_address\test_torch.py", line 1, in <module>
import torch
file "d:\py\python310\lib\site-packages\torch\__init__.py", line 143, in <module>
raise err
oserror: [winerror 126] 找不到指定的模块。 error loading "d:\py\python310\lib\site-packages\torch\lib\fbgemm.dll" or one of its dependencies.
问题解决
step 1|下载 dll 文件依赖分析工具 dependencies
下载地址:https://github.com/lucasg/dependencies/tree/v1.11.1
如果是 32 位系统,则下载 x86_release 文件。
step 2|使用 dependencies 分析报错 ddl 文件的依赖
解压后运行 dependenciesgui.exe 文件。
点击 file > open,选择依赖报错的 dll 文件。
通过上图,可以看到使用因为没有找到依赖的 vcomp140.dll 文件。
step 3|解决 vcomp140.dll 文件的问题
搜索 vcomp140.dll
文件,找到如下解决方案:https://www.bilibili.com/read/cv27989426/,发现可能需要重新安装 visual c++ redistributable 工具。
找到 microsoft 官网下载地址:https://www.microsoft.com/zh-cn/download/details.aspx?id=48145&751be11f-ede8-5a0c-058c-2ee190a24fa6=true
安装之,即可正常 import torch。
发表评论