How to place Jupyter kernels inside a virtual environment?

I have a custom Jupyter kernel that launches IPython using a custom IPython profile that uses matplotlib stylesheet.

I know that I successfully run this normally, I would put:

  • Matplotlib stylesheet in ~ / .config / matplotlib / stylelib /

  • IPython profile in ~ / .ipython /

  • The json kernel in ~ / .jupyter / kernels / my_kernel /

But I do this as part of a larger program that runs on virtualenv, and if I put things as described above, any laptop server running on the computer will be able to see user kernels, even if it runs outside of Vienna. I do not understand, because I do not want my program to interfere with other laptops on the computer.

I think I need to do things higher than somewhere equivalent inside venv, but I cannot figure out where they should go. Does anyone know where they will go? Or is it just a thing that IPITON / Jupiter cannot / will not do?

Perhaps it is worth mentioning that in the case of a style sheet, for example, I do not want to just put it in the working directory of my program (which is one of the matplotlib suggestions).

+4
source share
1 answer

You can put kernelspecs in VIRTUAL_ENV/share/jupyter/kernels/and they will be available if the laptop server is running on this env. Generally <sys.prefix>/share/jupyter/kernelsincluded in the kernelspecs search path.

, Jupyter, jupyter --paths:

$jupyter --paths

config:
    /Users/you/.jupyter
    /Users/you/env/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /Users/you/Library/Jupyter
    /Users/you/env/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /Users/you/Library/Jupyter/runtime

Kernelspecs , data:, kernels /usr/local/share/jupyter/kernels.

+4

Source: https://habr.com/ru/post/1627888/


All Articles