ImportError:无法加载 PyTorch C 扩展

Cor*_*nna 10 python torch

我在将 torch 导入到我的项目中时遇到问题,当我尝试导入它时,出现以下错误:

ImportError: Failed to load PyTorch C extensions:
     It appears that PyTorch has loaded the `torch/_C` folder
     of the PyTorch repository rather than the C extensions which
     are expected in the `torch._C` namespace. This can occur when
     using the `install` workflow. e.g.
         $ python setup.py install && python -c "import torch"

     This error can generally be solved using the `develop` workflow
         $ python setup.py develop && python -c "import torch" # This should succeed
     or by running Python from a different directory.

Not only with importing torch into your project but also with other libraries using it as a dependency.
Run Code Online (Sandbox Code Playgroud)

Python 3.10.10

火炬2.0.0

我尝试重新安装 torch,但没有成功,我不知道问题出在哪里,你能帮我吗?

Kar*_*rif -1

重新安装割炬

pip uninstall torch
pip install torch
Run Code Online (Sandbox Code Playgroud)