“import torch” giving error “from torch._C import *, DLL load failed: The specified module could not be found”

前端 未结 8 827
甜味超标
甜味超标 2020-12-20 12:51

I am currently using Python 3.5.5 on Anaconda and I am unable to import torch. It is giving me the following error in Spyder:

Python 3.5.5 |Anaconda, Inc.|          


        
8条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 13:35

    I had the same issue with running torch installed with pure pip and solved it by switching to conda. Following steps:

    1. uninstall python 3.6 from python.org (if exists)
    2. install miniconda
    3. install torch in conda ("conda install pytorch -c pytorch")

    Issue with pip installation:

    import torch
      File "C:\Program Files\Python35\lib\site-packages\torch\__init__.py", line 78, in 
        from torch._C import *
    ImportError: DLL load failed: The specified module could not be found.

    After switching to conda it works fine. I believe the issue was resolved by conda through installing the vs_redist 2017

    vs2017_runtime 15.4.27004.2010 peterjc123

    But I have tried it w/o conda and it did not help. Could not find how to check (and tweak) Python's vs_redist.

提交回复
热议问题