ROOT C++ kernel does not work in JupyterHub but work well in Jupyter-lab[Solved]

Dear,

I just installed JupyterHub by pip follow the instruction in https://jupyterhub.readthedocs.io/en/stable/quickstart.html#installation and https://github.com/jupyterhub/jupyterhub/wiki/Using-sudo-to-run-JupyterHub-without-root-privileges. After that, I installed R, matlab adn ROOT. The output of ‘jupyter kernelspec list’ is:
root /opt/root_v6.22.02/etc/notebook/kernels/root
python3 /home/zhangxf/.local/share/jupyter/kernels/python3
ir /usr/local/share/jupyter/kernels/ir
matlab /usr/local/share/jupyter/kernels/matlab

Althrough ROOT worked well when I start jupyter-lab, but it was very frustrated that ROOT cannot be started in Jupyterhub. The err log saied "ModuleNotFoundError: No module named 'ROOT' ". The content of /usr/local/share/jupyter/kernels/root/kernel.json is:
{
“language”: “c++”,
“display_name”: “ROOT C++”,
“argv”: [
“python3”,
“-m”,
“JupyROOT.kernel.rootkernel”,
“-f”,
“{connection_file}”
]
}

Both ROOT and JupyROOT/kernel/rootkernel.py could be found in /opt/root_v6.22.02/lib, and /opt/root_v6.22.02/lib has been added to $PYTHONPATH.

Any help will be greatly appreciated.Preformatted text

Well, this problem has been resolved by myself. The reason is spawner.

Followed the instruction on https://github.com/jupyterhub/jupyterhub/wiki/Using-sudo-to-run-JupyterHub-without-root-privileges, I can run JupyterHub without root privileges and at the same time other accounts in the server can log in jupyterhub. But the problem is the envorinment variables when you use spawner, i.e. it seemed that spawner only spwan specific envorinment variables other than current variables.

The solution was to create a script named sudospawner-singleuser in /usr/local/bin (Both jupyterhub-singleuser and sudospwaner are in this directory) to initialize user environment variables. The content was quite simple: