Torch is not found in jupyter notebook

I am using Ubuntu 18.04 and I have installed the anaconda and installed the pytorch using conda install pytorch-cpu torchvision-cpu -c pytorch. The import of pytorch works well in terminal but whenever I try to import it in jupyter notebook, it fails.

I have installed the whole anaconda two times but it is not working. I have tried with different environment but it is not working. I have also tried to update anaconda but it already up to date and also have tried to downgrad mkl to 2018


This is most certainly because your notebook is not using the same python as anaconda. You need to make sure that the notebook’s python is the one where you installed pytorch.

How can I know that which python my jupyter notebook is using and how can I change to use conda python?
New to this jupyter stuff😅

I don’t use jupyter either so I’m not sure :confused: You should be able to find info on google. And you can use .__file__ on any python object to see where it comes from. You can do import os; print(os.__file__) to see where the os library is, that should give you a hint of where the current python is installing packages :slight_smile:

The problem has resolved. I had two versions of jupyter notebook , one of pip and one of anaconda. I simply removed the pip packages and now it is working like a gem.
Thanks everyone for help.

1 Like

It doesn’t work for me. I’ve got no pytorch of pip. Both jupyter and anaconda run on python 3.7.7. Yet… Can someone smart tell me what to do? I’ve tried heaven and earth for a couple of days now without any success. All info from the internet has definitely been failing me.