-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to Import Packages that Installed with pip in JupyterLab module #375
Comments
I have a workaround solution is provide correct kernel at startup script and choose right kernel when create Notebook resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
startup_script = <<-EOT
set -e
.....
python3.12 -m pip install ipykernel --break-system-packages
python3.12 -m ipykernel install --user --name="Python3.12.3"
.....
EOT it works, but I think this is module's problem. |
The module uses |
It's unfortunate that the change breaks your use case. |
Maybe using |
This is my work around. Sleep is so ugly. I hope that jupyterlab module handles tools like poetry natively. |
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:
!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.import pandas as pd
in the Notebook. This raises aModuleNotFoundError
.Findings:
Output of
!which pip
in the Notebook: /usr/bin/pipOutput of
sys.executable
in the Notebook: /home/coder/.local/share/pipx/venvs/jupyterlab/bin/pythonIt 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.The text was updated successfully, but these errors were encountered: