Use nb_conda_kernels find conda python kernels
See original GitHub issueCurrently, I create separate conda environments for most projects to facilitate dependency management. nb_conda_kernels
supports this workflow since I only need to install jupyterlab in a single conda env. However jupyterbook is not aware of python kernels outside the environment it is installed in, so it needs to be installed in each conda environment separately. The kernel name in the notebook also needs to be changed manually to python3
instead of e.g. conda-myenvname-py
because the latter throws an error saying the kernel cannot be found.
It would be great if jupyterbook could also make use of nb_conda_kernels
to execute notebooks with the specified conda kernel, similarly to how jupyterlab does it.
Related: https://github.com/executablebooks/meta/discussions/222 and https://github.com/executablebooks/jupyter-cache/issues/63
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
In case anyone else comes across this, my current workaround is to install jupyter-book in the environment that has the packages you want to use. Then, instead of changing the kernel names of each notebook manually, you can edit the jupyterbook utils file to specify the kernel name (e.g.
~/miniconda3/envs/jb_conda_env/lib/python3.9/site-packages/jupyter_cache/executors/utils.py
). You need to addkernel_name='python3'
as an input parameter to theexecutenb
function at the end of this file.Adding a note that nb_conda_kernels did add a mechanisms for it to be used with other applications than jupyterlab, etc in an earlier release https://github.com/Anaconda-Platform/nb_conda_kernels/releases/tag/2.3.0. I am not sure it would be helpful here but adding it just in case.