I have installed pytorch in virtual environment. When I am trying to execute import torch from Jupyter notebook I am getting error as below.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-10-eb42ca6e4af3> in <module>
----> 1 import torch
ModuleNotFoundError: No module named 'torch'
But when I am running the same in Using Anaconda command prompt, import torch is successful. I am running Jupyter in windows 64 Anaconda environment
I have the same issue.
I've seen this (issues/4827), which is related to the missing lib mkl. But, in my case, I have mkl-2019.4 and it still doesn't work.
What is awkward is that this import works fine in spyder, the problem is only in jupyter notebook.
It turns out that the version mkl-2019.4 doesn't really work. I have installed the 2018 and it's fine now.
conda install mkl=2018
I had the same issue. 'import torch' worked on the terminal but it didn't work on the Jupyter.
First, on the Jupyter, try to type and see the output of:
print(sys.executable)
I found that the location of the executable was from a different conda environment.
What finally worked for me was:
At least it worked for me after hours of frustrating moment. Hope it helps.
if nothing work with you try to install Jupiter notebook from anaconda navigator
it's the only way it works with me
https://janakiev.com/blog/jupyter-virtual-envs/
This fixed my issue. If it helps anyone
I solved this issue by installing Jupyter notebook in current environment.
Most helpful comment
I had the same issue. 'import torch' worked on the terminal but it didn't work on the Jupyter.
First, on the Jupyter, try to type and see the output of:
I found that the location of the executable was from a different conda environment.
What finally worked for me was:
> Python [conda env: XXX]
where XXX is whatever the name of the conda environment where Pytorch was set up.
At least it worked for me after hours of frustrating moment. Hope it helps.