Can't install extensions in JupyterLab due to pip error #210
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Recently, Python's PEP 668 has started to take effect in a lot of distros, so
pip install
no longer works. The problem it's trying to solve is thatpip install
will use globally installed (using pacman) Python packages as dependencies, so when those globally installed packages are uninstalled or upgraded, you could and probably will get breakage.Some possible solutions:
Do things the old way: There are several ways to do that listed here (you probably want to modify
~/.config/pip/pip.conf
), but this can and probably will lead to breakage (such as #125, #198, #202). If your extension breaks, you'll just have to reinstall it.Create a venv and install JupyterLab inside. This won't lead to breakage, but hub.exozy.me won't use the venv's JupyterLab but rather will use the globally installed JupyterLab. This means that if you start JupyterLab at hub.exozy.me, pip still won't work, and you would have to SSH in, source the venv, and start JupyterLab manually instead.
Use Conda. Wait, this is a joke. Conda will probably give you more pain.
Wait until JupyterLab upstream finds a way to solve this issue. The PEP 668 rollout has just started, so eventually people will start complaining and JupyterLab might find a better way to solve this.
TL;DR Python packaging sucks and PEP 668, which is trying to make it suck less, has managed to make it suck in other ways. Also, all hell breaks loose after a Python major version upgrade (Python 3.12 is sooner than you think). If you want JupyterLab extensions to work right now, then modify
~/.config/pip/pip.conf
as suggested above and cross your fingers that nothing breaks over the next few months.The core of this problem is that JupyterLab assumes it's running in an environment where it has write access to Python packages, but this isn't the case for distro-installed JupyterLab.
Thus, I think the only sane solution for this is to not support installing extensions on hub.exozy.me. If you want to use JupyterLab extensions, you should make your own venv for that.
I also posted on Matrix:
This turns out to not work because in the JupyterHub code, it actually uses the root user's PATH when spawning the process and then setuids it to the correct user, so I would need to write a script called
jupyterhub-singleuser
and put it on the root user's PATH that gets the user's default shell and runs thejupyterhub-singleuser
command using the user's PATH and falls back to/usr/bin/jupyterhub-singleuser
. (Actually, this might be wrong and perhaps what actually happens is that JupyterHub spawns the process using Bash. Anyways it's complicated and IMHO not worth spending more time on. Just make a venv)