Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support manual kernel names for notebook execution #1287

svenkreiss opened this issue Apr 4, 2021 · 4 comments

Support manual kernel names for notebook execution #1287

svenkreiss opened this issue Apr 4, 2021 · 4 comments
enhancement New feature or request


Copy link

Is your feature request related to a problem? Please describe.

I don't know how to stop my editor (VSCode) to assign strange kernel names to Jupyter notebooks, for example python392jvsc74a57bd029864609ce42acb949f1cb2f5c54b....
Other tools (nbconvert) allow me to specify a kernel to execute the notebook with independent of the kernel the notebook was created with.

Describe the solution you'd like

The tool nbconvert has a command line option --kernel_name that allows to specify the kernel name no matter what is in the notebook's metadata:
Such a command line option would be great.

Describe alternatives you've considered

I can edit notebooks with jq and set the kernel name. That is quite unreliable. The other day it changed the indentation of all my notebooks leading to a git diff that I had to revert and I lost some edits.

for fn in *.ipynb; do
    jq '(,.metadata.kernelspec.display_name)="python3"' ${fn} > ${fn}_
    mv ${fn}_ ${fn}

Additional context

I think VSCode is not the only editor that writes unqiue kernel names into the notebook metadata. Any editor that does that breaks a development flow where the public version of the book is built in a continuous integration service that doesn't have access to the local kernels.

@svenkreiss svenkreiss added the enhancement New feature or request label Apr 4, 2021
Copy link

welcome bot commented Apr 4, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

Copy link

Note the issue with VS Code is now fixed, in that it now sets standard kernel names like 'python3': microsoft/vscode-jupyter#5732

@choldgraf choldgraf changed the title --kernel_name Add --kernel_name parameter for notebook execution Aug 3, 2021
@choldgraf choldgraf changed the title Add --kernel_name parameter for notebook execution Support manual kernel names for notebook execution Aug 3, 2021
Copy link

I would love to see this as well, especially if it was able to use conda kernels since it would also solve #1348

Copy link

My current workaround for CI/CD is to manually make jupytext set all the various notebooks to the right environment, like jupytext --set-kernel - content/**/*

  • This requires me to add an to the extension, since otherwise jupytext tries to add kernel metadata to non-executable .md files.
  • Doesn't allow jupyter-book to change the executing kernel on-the-fly, e.g. I have nb_conda_kernels locally to make managing project environments sane, but jupyter-book lives with my notebooks environment, not the project environment where the content is written. You can mitigate this (workaround for Use nb_conda_kernels find conda python kernels #1348) in mamba using mamba activate notebooks && mamba activate project-env --stack to get jupyter-book working in the project environment, but that's a massive hack 😅

Would really love to see this feature!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
enhancement New feature or request
None yet

No branches or pull requests

4 participants