Avoiding issues with shared kernels

tldr: If users of TLJH are having trouble connecting to shared kernels try creating a new admin user and install the packages from that new user.

I have installed TLJH and am using it to share access to a group computer for scientific research. I just spent numerous hours trying to install a new kernel available to all users on my server. I wanted to post the solution I found in case others face a similar issue.

Quick overview: I used sudo -E conda create --name new_kernel python=3.8 to create a new environment for the kernel. Then I used sudo -E pip install package_name to install the package and dependency. Then I add the new kernelspec. However, only my user was able to use this kernel. Others would just say “Connecting…” and then time out as “Disconnected…”

The problem: My admin user has packages installed in ~/.local/lib/python3.8/ which pip used for this kernel. These were possibly installed by mistake without sudo -E earlier. Other users were not able to access these packages and their kernel connections would fail. I tried many ways to get pip to ignore these packages to no avail.

Solution: I created a new “clean” admin user and did the install using that user. This user has NO packages in the ~/.local/lib/ directory and the install went perfectly.