skip to Main Content

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

2

Answers


  1. 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.

    Login or Signup to reply.
  2. Ubuntu CLI is not the same environment with jupyter.
    In Jupyter run this command%pip install <package name>

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search