JupyterLab vs virtualenv - cant find installed python package. Linux

Viewed 15

CentOS9. latest jupyter lab and python3.

I always thought that Jupyter is agnostic to the virtualenv and that it is the ipykernel which "knows" its environment

What I did:

  • created virtual environment
  • activated it
  • installed kernel ipython kernel install --user --name=pt
  • installed pytorch
  • checked it with running python3
import torch
torch.__version__
  • ran jupyterlab --no-browser
  • opened browser and jupyter launcher, created new notebook with kernel pt
  • tried torch got error:
import torch
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 import torch

ModuleNotFoundError: No module named 'torch'

What am I doing wrong?

1 Answers

Apparently you need to install kernel differently:

pt/bin/python3 -m ipykernel install --name "pt"
Related