小工具知识网

当前位置: 首页 > 行业知识 > ImportError: Failed to load PyTorch C extensions

行业知识

ImportError: Failed to load PyTorch C extensions

2026-10-26 03:47:00 来源:互联网转载

问题描述

在项���中安装其他的库之后,运行项目忽然报这个错:

ImportError: Failed to load PyTorch C extensions:It apperas that PyTorch has loaded the `torch/_C` folderof the PyTorch repository rather than the C extensions whichare expected in the `torch._C` namespace. This can occur whenusing the `install` workflow. e.g.  $ python setup.py install && python -c "import torch"This error can generally be solved using `develop` workflow  $ python setup.py develop && python -c "import torchi" # This should succeedor by running Python from a different directory.Process finished with exit code 1

解决办法

在项目里重装 torch库就好了。

pip uninstall torch==1.10.2pip install torch==1.10.2

上一篇:ViLT学习

下一篇:详解Python中的str函数,功能、用法及注意事项全解析