coder / coder/registry

Unable to Import Packages that Installed with pip in JupyterLab module

Open
#35 6 comments 1 reaction 0 assignees View on GitHub
help wanted
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.