Search code examples
pytorchcondavirtualenv

Installed torch in conda env and activated the env but got No module named torch


I successfully installed torch in conda env, but when I'm tring to use torch, I got No module named torch

I used pip list | grep torch, and got:

  • torch 2.1.1
  • torchaudio 2.1.1
  • torchvision 0.16.1

and also, I deactivated the conda env and then activated it again to make sure I use the env. But when I tried to import torch, I still got No module named torch.

Could anyone can help to solve this problem?


Solution

  • You have either

    • not installed torch in the environment you thought you had
    • or you are not using the environment you think you use.

    I made you a screenshot where you can follow the very same steps to activate an run torch, maybe it helps you to find the error?

    enter image description here