Torch is running successfully in VSCode but gives error in Jupyter Notebook

Viewed 147

I installed torch after creating the anaconda virtual environment using the following commands:

pip3 install torch torchvision torchaudio

Then I run the following commands in VSCode successfully:

import torch
print(torch.__version__)

However, the above commands in the Jupyter notebook return the following error:

ModuleNotFoundError: No module named 'torch'

I used the same Anaconda virtual environment for both. I have windows 10 OS.

Can anyone tell me why should there be an error in the Jupyter notebook? and how to fix this error? Should I install the torch using conda but then should I remove the pip installation?

1 Answers

Try to install the numpy jupyter notebook that supports PyTorch,

launch your notebook again while in you're in virtual env path

Related