Can not import torch

I have installed pytorch using following command

pip install --user torchvision

But When I try to import it I am getting error

 Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named torch

Also it says that all the requirements are satisfied

 Requirement already satisfied: torchvision in ./.local/lib/python3.6/site-packages (0.2.1)
Requirement already satisfied: six in /usr/lib/python3/dist-packages (from torchvision) (1.10.0)
Requirement already satisfied: torch in ./.local/lib/python3.6/site-packages (from torchvision) (0.4.0)
Requirement already satisfied: pillow>=4.1.1 in ./.local/lib/python3.6/site-packages (from torchvision) (5.2.0)
Requirement already satisfied: numpy in ./.local/lib/python3.6/site-packages (from torchvision) (1.14.5)

What should I do?

2

1 Answer

  1. Visit torch - PyPi.

  2. Click the "Download files" link.

  3. Clicking the "Download files" link will expose the torch file to download. At the time of posting this answer the name of the torch file is: torch-0.4.1.post2-cp37-cp37m-manylinux1_x86_64.whl.

  4. Open the terminal and type:

    pip3 install
    pip3 install --user torchvision 
  5. Start the Python 3 interpreter with the command python3 and from the python3 prompt type:

    import torch 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like