Open
Description
I use the jupyter-lab
module in main.tf with default parameters. However, when I create a new Notebook, I encounter issues with importing packages installed using pip.
Steps to reproduce:
- In a Notebook, run
!pip install pandas --break-system-packages
(using--break-system-packages
to bypass theexternally-managed-environment
error). The package gets installed to ~/.local/lib/python3.12/site-packages. - Run
import pandas as pd
in the Notebook. This raises aModuleNotFoundError
.
Findings:
Output of !which pip
in the Notebook: /usr/bin/pip
Output of sys.executable
in the Notebook: /home/coder/.local/share/pipx/venvs/jupyterlab/bin/python
It seems that when JupyterLab is installed via pipx, it uses its own Python environment, separate from the system's pip. As a result, packages installed via pip are not accessible to JupyterLab.
Expected behavior:
Packages installed using !pip install
in a Jupyter notebook should be available for import without additional configuration.