Cannot import Pytorch [WinError 126] The specified module could not be found

前端 未结 5 2226
离开以前
离开以前 2021-02-18 15:31

I\'m trying to do a basic install and import of Pytorch/Torchvision on Windows 10. I installed a Anaconda and created a new virtual environment named photo. I opened Anaconda pr

相关标签:
5条回答
  • 2021-02-18 15:59

    Uninstall your pytorch which you have installed and try this using conda

    conda install PyTorch -c PyTorch
    

    If it wasn't work run this code in cmd

    pip3 install torchvision
    
    0 讨论(0)
  • 2021-02-18 15:59

    You should use the command line to install PyTorch on Windows or any supported platform. It is trivial:

    • Open URL in web browser https://pytorch.org/
    • Find the "Quick Start Locally" section
    • Select your platform
    • Run the command on your end (highlighted in yellow)

    This way you can install it with any following package:

    • Conda
    • Pip
    • LibTorch
    • Source
    0 讨论(0)
  • 2021-02-18 16:05

    Encountered the same issue. I used the fix suggested in by the link below: (Fix 2 worked for me)

    https://discuss.pytorch.org/t/winerror-126-when-import-torch/80249/8

    Fixes:

    1.Update to Python 3.8 from 3.7

    2.Apply https://github.com/pytorch/pytorch/pull/37763 manually.

    Replace your local copy with https://gist.github.com/peterjc123/bcbf4418ff63d88e11313d308cf1b427 (e.g. C:\ProgramData\Anaconda3\Lib\site-packages\torch)

    0 讨论(0)
  • 2021-02-18 16:05

    I have installed Microsoft Build Tools from https://visualstudio.microsoft.com/visual-cpp-build-tools/ I have checked all boxes regarding C++ section.

    Before this I could only import torch from Jupyter notebook but not from ipython or python shell. I don't why that's so but it works now.

    0 讨论(0)
  • 2021-02-18 16:11

    Refer to below link: https://discuss.pytorch.org/t/cannot-import-torch-on-jupyter-notebook/79334

    This is most probably because you are using a CUDA variant of PyTorch on a system that doesn’t have GPU driver installed. That is to say, if you don’t have a Nvidia GPU card, please install the cpu-only package according to the commands on https://pytorch.org.

    Conda

    conda install pytorch torchvision cpuonly -c pytorch

    Pip

    pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html

    0 讨论(0)
提交回复
热议问题