I know someone created a similar topic but it remained unsolved. I installed PyTorch last week through the ‘conda install pytorch torchvision -c pytorch’ command on the terminal in my Mac and it worked for a few days. This week it’s not working anymore, with the message “No module named Torch” on the output screen.
I’m in conda’s environment (as you can see in the picture) and I’ve tried all the possible environments. I also reinstalled PyTorch through the terminal and I installed PyTorch Snippets and it still doesn’t work…
It seems like you didn’t properly setup the python interpreter path (for your situation, it is something like <path to anaconda>/env/pytorch/bin/python).
I would recommend to use the integrated terminal (Win: ctrl + j, MacOS: command + j) of VS Code to run the script, where you can activate your conda environment with conda activate pytorch.
It works on the integrated terminal, so I can use it, but on the VS Code editor it still doesn’t work. I’m attaching the pics of the environment I am in ~/opt/anaconda3/envs/pytorch/bin/python (which should be the same as in the terminal), and still raises the “No module named torch” error.
Can you give more details how you “run in vscode editor”? Is it a feature of the “pytorch snippet” extension?
EDIT: maybe you could open your settings.json (command+,, then click the button on the top-right corner), just make sure that the default python path is the right one.
Yes, now I see the problem is in running the code from the editor to the output screen. When I run it from the editor to the terminal it works.
So I click at the top right button “Run Python file in Terminal” and it works, but when I click “Run code” so I have it on the output screen it shows the message “No module named torch”.
Yes I have it. I think I don’t know how to write the path in my mac because now the output is as in the following picture (and the path I wrote is next):
Do you mean VS Code extensions or python modules?
I think you don’t need extra extensions to use tensorflow or matplotlib. You could install them via conda or pip just like how you installed pytorch.