I met problem of " ModuleNotFoundError: No module named ‘torch’ , when I try to import torch in the Pycharm CE.
I tried to install the module with Pycharm but it still did not work.
However, when I try to import torch in the terminal by scrapy shell mode, “import torch” is successful.
I used the interpreter as the pic attached since I used the anaconda to install the Pytorch. But it still does not work. The output is "ModuleNotFoundError: no module named ‘torch’ ".
2.) Follow the instructions of pytorch.org for your specific system (But you have to add “sudo” before you paste the instructions pip3 …)
3.) After that you change your project interpreter in PyCharm, with 1) settings → project interpreter /show all → plus symbol → add local → choose your system interpreter → Finally you change the project interpreter on system interpreter and here was the modules installed already
At the last point you can verify it by pasting the following code:
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
Thanks a lot! I have solved this problem following your suggestion. In particular, I also changed the "edit configuration" to the right interpreter, then the problem was finally solved.