No module named “Torch”

前端 未结 13 917
慢半拍i
慢半拍i 2021-01-04 01:41

I installed pytorch via

conda install pytorch-cpu torchvision-cpu -c pytorch

And I also tried

pip3 install https://download.pytorch         


        
相关标签:
13条回答
  • 2021-01-04 02:21

    Check SDK install. you also install the sdk in your environment.

    You can install the SDK using navigator.

    first, change tab to Environments,

    second, push play button of your environment name.

    Third, then install SDK.

    0 讨论(0)
  • 2021-01-04 02:24

    I had the same problem after following the official installation guide in here. I realized that it was my stupid Atom built-in terminal.

    Inside the atom terminal, which python returned /usr/bin/python, although it showed the mark of (conda_env)$.

    I fixed it by opening a new terminal and activating the (conda_env), and it worked. Verified and which python yields /Users/my_usr/anaconda3/envs/conda_env/bin/python

    0 讨论(0)
  • 2021-01-04 02:25

    I installed on my macos by the official command:

    conda install pytorch torchvision -c pytorch
    

    but when I follow the official verification I get the same problem like yours.

    Then I create a conda virtual environment:

    conda create --name learnpytorch python=3.5
    

    and install pytorch inside the environment:

    conda install pytorch torchvision -c pytorch
    

    run the verification, it works.

    Hope these could help you.

    0 讨论(0)
  • 2021-01-04 02:26

    You need to add this at the very top of your program

    import torch
    

    If this is not a problem execute this program on both Jupiter and command line and pretty much you will understand if you have a mismatch.

    import sys
    print(sys.executable)
    
    0 讨论(0)
  • Create the environment:

    conda create -n env_pytorch python=3.6
    

    Install your modules. For example:

    conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
    

    Next time you want to use pytorch:

    conda activate env_pytorch
    

    and when finished:

    conda deactivate
    
    0 讨论(0)
  • 2021-01-04 02:30

    Make sure that NumPy and Skipy libraries are installed before installing the torch library that worked for me at least on windows.

    step 1. Install NumPy: pip install numpy
    step 2. Install Skipy: pip install skipy
    step 3. Go to pytorch.org and select your needs and copy the address
    step 4. Paste the address and download

    Hope that works for you as well ( :

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