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.

Command line execution of a jupyter notebook fails in default Anaconda 4.1.

See original GitHub issue

From @rtrhd on July 2, 2016 15:30

Command line execution of a jupyter notebook with jupyter nbconvert --to notebook --execute fails after upgrading to Anaconda 4.1.

On saving a jupyter ipython notebook the kernel name is changed from the conventional python2 or python3 to the conda specific form Python [Root] but this is not recognised by nbconvert.

This form is also not recognised when the notebook is opened in the browser in an Anaconda 4.0 installation causing problems sharing notebooks.

The behaviour was observed on OSX/3.5 and Linux/2.7.

Explicit removal of the package nb_conda_kernels resolves the problem, but this package is included by default in Anaconda 4.1.

jupyter nbconvert --to notebook --execute test_python_root.ipynb
[NbConvertApp] Converting notebook test_python_root.ipynb to notebook
[NbConvertApp] Executing notebook with kernel: Python [Root]
Traceback (most recent call last):
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 173, in get_kernel_spec
    resource_dir = d[kernel_name.lower()]
KeyError: 'python [root]'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/ron/anaconda3/bin/jupyter-nbconvert", line 6, in <module>
    main()
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/traitlets/config/application.py", line 596, in launch_instance
    app.start()
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 293, in start
    self.convert_notebooks()
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 457, in convert_notebooks
    self.convert_single_notebook(notebook_filename)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 428, in convert_single_notebook
    output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/nbconvertapp.py", line 357, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 165, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 183, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/exporters/notebook.py", line 26, in from_notebook_node
    nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 130, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/exporters/exporter.py", line 302, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/preprocessors/base.py", line 47, in __call__
    return self.preprocess(nb,resources)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/nbconvert/preprocessors/execute.py", line 141, in preprocess
    cwd=path)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_client/manager.py", line 429, in start_new_kernel
    km.start_kernel(**kwargs)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_client/manager.py", line 230, in start_kernel
    kernel_cmd = self.format_kernel_cmd(extra_arguments=extra_arguments)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_client/manager.py", line 170, in format_kernel_cmd
    cmd = self.kernel_spec.argv + extra_arguments
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_client/manager.py", line 82, in kernel_spec
    self._kernel_spec = self.kernel_spec_manager.get_kernel_spec(self.kernel_name)
  File "/Users/ron/anaconda3/lib/python3.5/site-packages/jupyter_client/kernelspec.py", line 175, in get_kernel_spec
    raise NoSuchKernel(kernel_name)
jupyter_client.kernelspec.NoSuchKernel: No such kernel named Python [Root]

Copied from original issue: ContinuumIO/anaconda-issues#877

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ijstokescommented, Jul 7, 2016

Ack, this is pretty bad. We need to figure out a much better solution to this problem. nbconvert is a thing lots of people do. I’m going to move this to nb_conda_kernel repo where the action will take place (and where the problem originates).

1reaction
damianavilacommented, May 3, 2017

Suggestion: remove any kernelspec from /.local/share/jupyter. That is probably clobbering the kernel in you environment…

If I run jupyter kernelspec list I see:

$ jupyter kernelspec list
Available kernels:
  python3    /media/data/miniconda3/envs/conda-test/share/jupyter/kernels/python3

Which is the python executable in you conda-test environment.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What to do when things go wrong - The Jupyter Notebook
If you're using a menu shortcut or Anaconda launcher to start it, try opening a terminal or command prompt and running the command...
Read more >
Jupyter notebook command does not work on Mac
I managed to solve the case in OS X El-Capitan 10.11.5 and Ubuntu Linux 16.04. My Jupyter version after the upgrade is 4.1.0....
Read more >
Running the Notebook - Jupyter Documentation
Using a command-line interface#. Notebooks can be executed from your terminal using the run subcommand. It expects notebook paths as input arguments and...
Read more >
Installation Runbook (AEN 4.1.0) - Anaconda Documentation
This installation runbook walks through the steps needed to install a basic Anaconda Enterprise Notebooks system comprised of the front-end server, gateway, ...
Read more >
Common Illnesses — Spyder 5 documentation
If you receive the message An error occurred while starting the kernel in the IPython Console, Spyder was unable to launch a new...
Read more >

github_iconTop Related Medium Post

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