custom location for kernels?

1,129 views
Skip to first unread message

Michael Gilbert

unread,
Jan 22, 2016, 7:04:09 PM1/22/16
to Project Jupyter
I would like to install kernels for all users of jupyterhub in a single directory and have that directory get checked for which kernels to load, as opposed to the user's .local/share/jupyter directory. According to http://jupyter-client.readthedocs.org/en/latest/kernels.html#kernel-specs, setting the JUPYTER_PATH variable should allow jupyter to see kernels in a different location. However, this doesn't seem to work. Does this variable need to be set for the master user that starts jupyterhub or can it just be set for each user before they invoke a spawner?

What I'm currently doing is having each user point to a central location that has a global kernels directory with other dirs like "ir" "python2" and so forth. In turn, each of these directories has kernel.json files that I have verified do work. When I do `export JUPYTER_PATH=${KERNEL_DIR}` for the user, and the user doesn't have a local kernel directory, then only python3 shows up in the dropdown.

Can anyone shed some light on how I can go about doing this global kernel directory?

Thanks!

Mike

Thomas Kluyver

unread,
Jan 23, 2016, 4:09:36 AM1/23/16
to Project Jupyter
On 23 January 2016 at 00:04, Michael Gilbert <mk...@nau.edu> wrote:
I would like to install kernels for all users of jupyterhub in a single directory and have that directory get checked for which kernels to load, as opposed to the user's .local/share/jupyter directory. According to http://jupyter-client.readthedocs.org/en/latest/kernels.html#kernel-specs, setting the JUPYTER_PATH variable should allow jupyter to see kernels in a different location. However, this doesn't seem to work. Does this variable need to be set for the master user that starts jupyterhub or can it just be set for each user before they invoke a spawner?

If there's any interaction with Jupyterhub, it's probably that something is resetting the environment variables when starting processes. That environment variable needs to be set in the user's notebook server process.

However, I'm not sure why you need an environment variable at all. There are already systemwide directories where kernelspecs can be installed. On a Unix system, those are:

/usr/share/jupyter/kernels
/usr/local/share/jupyter/kernels

The notebook server should see kernelspecs in there without you needing to set JUPYTER_PATH at all.

Thomas

Michael Milligan

unread,
Jan 23, 2016, 7:12:32 PM1/23/16
to Project Jupyter
You also can avoid using system paths completely, since the path /share/jupyter/kernels is searched for in sys.prefix too. So for example in my case, I install the kernelspec directories under /path/to/anaconda/share/jupyter/kernels

And incidentally, it is additive, not "as opposed to" -- if the user has a .local/share/jupyter/kernels directory, any kernels they define will be added to the list of available kernels. Annoyingly, if they use the same directory name as one of your globally installed kernels, even if the display name is different, their kernel will replace the global one in the list.

Michael

Kyle Kelley

unread,
Jan 23, 2016, 9:02:15 PM1/23/16
to jup...@googlegroups.com
Keep in mind that the sys.prefix is based on the running Python. This means that Anaconda, conda, and virtualenv installs of jupyter can all have their own Python kernel that would ignore the sys.prefix of the base python installation. Good thing: that's a feature! Bad thing: you can't expect users to see your globally installed kernels. Solution: use the paths that Thomas suggests. I'm vehemently opposed to including sys.prefix, as we're again tying ourselves to python, and not just any python - the python that jupyter is running in.



--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/a53bd9d3-a90d-47b3-a0bd-7b8cfda1cdd8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Kyle Kelley (@rgbkrklambdaops.com)

Michael Milligan

unread,
Jan 24, 2016, 6:10:56 AM1/24/16
to jup...@googlegroups.com
Well, in my case, I had to use the sys.prefix approach, because the jupyter configs needed to go on a shared filesystem, but on our cluster /usr is local to the node. If there was a configuration option to simply set the global configuration directory, I would happily use that instead.

Michael

--
You received this message because you are subscribed to a topic in the Google Groups "Project Jupyter" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jupyter/bOGfNogIzrM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jupyter+u...@googlegroups.com.

To post to this group, send email to jup...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Michael Milligan, Ph.D.         | Supercomputing Institute
Scientific Computing Consultant | University of Minnesota
Application Software Manager    | mill...@msi.umn.edu
www.msi.umn.edu/users/milligan  | Phone: 612-624-8857

Thomas Kluyver

unread,
Jan 24, 2016, 7:00:54 AM1/24/16
to Project Jupyter
On 24 January 2016 at 11:10, Michael Milligan <mill...@msi.umn.edu> wrote:
Well, in my case, I had to use the sys.prefix approach, because the jupyter configs needed to go on a shared filesystem, but on our cluster /usr is local to the node. If there was a configuration option to simply set the global configuration directory, I would happily use that instead.

There's the JUPYTER_PATH environment variable:
http://jupyter.readthedocs.org/en/latest/system.html#data-files

Alternatively, if it makes no sense to install kernels in /usr, you could symlink /usr/share/jupyter/kernels to whatever location does make sense.

Thomas

Michael Kit Gilbert

unread,
Jan 24, 2016, 3:14:29 PM1/24/16
to jup...@googlegroups.com

That is precisely the issue we have on out cluster. Thanks everyone for the feedback! I'll try the sys.prefix approach.

Reply all
Reply to author
Forward
0 new messages