Error when "import torch" after change confiugration to ./virualenvs

Why I have a problem when import torch using Jupyter?

I properly ran no problem with pip3 until I changed to PyCharm by using .virtualenvs to import libraries.
after I configured that I I cannot import a torch when running with Jupyter Notebook. Any Ideas to ignore this situation for configuration? Should we use pip3 or ./virtualenvs or any?

It might be that your jupyter notebook is pointing to a different python path than the one you have PyTorch installed on.

You can run

import sys
sys.executable

to check which python is being used in Jupyter.

I use conda to manage my environments and the output for the above code looks similar to this

'/Users/user_name/anaconda/envs/env_name/bin/python'
1 Like

@Viraat: Thanks, I solved it by installed anaconda as your suggestion, then I also installed both python3 -m pip3 install ipykernel and python3 -m pip3 install -user.

To keep things clean I would suggest using Conda to install jupyter as well. If you haven’t tried it out you should have a look at Jupyter lab. It’s in beta but it’s very neat!

1 Like