ModuleNotFoundError: No module named 'torch' in ubuntu

Question:

When I want use torch in jupyter, I got this error

ModuleNotFoundError: No module named 'torch'

but I check that torch is installed already. following:

>>> python -c "import torch; print(torch.__version__)"
1.10.2+cu102

It is confirmed in Ubuntu CLI, but there is an error in jupyter only.

How can I fix it??

  • OS : Linux(Ubuntu 18.04)
  • Python : 3.6
Asked By: Lee na-hyeon

||

Answers:

You have to install torch in the current jupyter kernel.
Run within your script:

import sys
!{sys.executable} -m pip install torch

See Details here.

Answered By: GeorgUr

Ubuntu CLI is not the same environment with jupyter.
In Jupyter run this command%pip install <package name>

Answered By: jp1527
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.