Unable to Import Packages that Installed with pip in JupyterLab module
- Dominant language
- HCL
- Stars
- 79
- Forks
- 161
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 38
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:
1. In a Notebook, run `!pip install pandas --break-system-packages` (using `--break-system-packages` to bypass the `externally-managed-environment` error). The package gets installed to ~/.local/lib/python3.12/site-packages.
2. Run `import pandas as pd` in the Notebook. This raises a `ModuleNotFoundError`.
### 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.
Contributor guide
Assessment
This issue has not been assessed yet.