question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nb_conda_kernels not found when using nbconvert --execute

See original GitHub issue

I am trying to run a notebook that uses a kernel from an automatically registered environment like this:

jupyter nbconvert --to notebook --execute advanced_mapping.ipynb

I am getting:

[NbConvertApp] Converting notebook advanced_mapping.ipynb to notebook
[NbConvertApp] Executing notebook with kernel: testenv
Traceback (most recent call last):
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/jupyter_client/kernelspec.py", line 201, in get_kernel_spec
    resource_dir = d[kernel_name.lower()]
KeyError: 'conda-env-testenv-py'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/croth1/miniconda2/envs/sci36/bin/jupyter-nbconvert", line 6, in <module>
    sys.exit(nbconvert.nbconvertapp.main())
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 305, in start
    self.convert_notebooks()
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 473, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 444, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/nbconvertapp.py", line 373, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 171, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 189, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/exporters/notebook.py", line 31, in from_notebook_node
    nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 131, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/exporters/exporter.py", line 308, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb,resources)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 207, in preprocess
    cwd=path)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/nbconvert/preprocessors/execute.py", line 188, in start_new_kernel
    km.start_kernel(**kwargs)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/jupyter_client/manager.py", line 244, in start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/jupyter_client/manager.py", line 175, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/jupyter_client/manager.py", line 87, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/home/croth1/miniconda2/envs/sci36/lib/python3.6/site-packages/jupyter_client/kernelspec.py", line 203, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named conda-env-testenv-py

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mpacercommented, Feb 26, 2018

Note this issue discussing these problems on nbconvert: https://github.com/jupyter/nbconvert/issues/515

1reaction
mcg1969commented, May 30, 2018

It’s not clear to me that there is anything that can be done about this within nb_conda_kernels itself without monkeypatching the nbconvert package. That said, the work being done in Jupyter 6 to refactor the way kernels are discovered should benefit all Jupyter-based packages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Executing notebooks — nbconvert 7.2.6 documentation
When not specified or when using nbconvert <4.2, the default Python kernel is chosen. Execute/Run (preprocess): To actually run the notebook we call...
Read more >
nbconvert Execute Jupyter notebook from Command Line ...
I tried stdout to python but there will no output. If I use html or notebook, if will include output. Even thought the...
Read more >
nbconvert Documentation - Read the Docs
15 Python API for working with nbconvert. 105. 15.1 NbConvertApp . ... Note: This does not enable slides that run completely offline.
Read more >
Unexpected working directory when running `ipynb` notebook ...
When I now try to run the notebook using nbconvert as follows: ... the working directory to be the directory I ran the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found