Notebook: Running cells is broken / cells execute in wrong order

Created on 11 Oct 2018  路  8Comments  路  Source: jupyter/notebook

Since I upgraded Jupyter to 5.7.0 a few days ago I noticed the following several times both at work and at home:

When I click "Kernel" -> "Restart & Run All" some cells are skipped and the following cells fail execution (because they depend on results of the previous cells).

Also executing multiple cells with Shift-Enter also produces the same problem.

Here's an example:

restartrunall

As you can see the cell with e = d + 1 was skipped and the following cell with f = e + 1 failed because it depends on e.

The result is not deterministic - when I repeat it, the problem either happens at another cell or (most often) not at all.. you might have to try quite a few times.

Sometimes it also skips more than one cell before failing. (Maybe it's not skipping cells - but executing them in the wrong order?)

jupyter

Most helpful comment

Upgrading ipykernel to version 5.1.0 solved this problem for me.

All 8 comments

This shows that cells are not skipped, but executing in the wrong order:

wrongorder

(As above - not deterministic.. might have to try several times)

I just downgraded notebook to my previous version of 5.5.0 (with conda install notebook=5.5)... and the problem persists!?

What other packages could be causing this? (I ran conda update --all a few days ago...)

987

I found a conda environment that I created a few months ago and the problem does not happen there.

So I tried downgrading single packages until the bug disappeared - it looks like the package ipykernel is responsible for the bug.

The problem happens with ipykernel 5.0.0, but does not happen with 4.8.2 (that was my previously installed version).

ipykernel 4.10.0 also does not have this bug.. looks like it was introduced somewhere between 4.10.0 and 5.0.0.

Upgrading ipykernel to version 5.1.0 solved this problem for me.

I reinstalled ipykernal, but now a kernal does not load. with the following issue:

Traceback (most recent call last):
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\web.py", line 1592, in _execute
    result = yield result
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\notebook\services\sessions\handlers.py", line 73, in post
    type=mtype))
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 79, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1141, in run
    yielded = self.gen.throw(*exc_info)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 92, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\tornado\gen.py", line 326, in wrapper
    yielded = next(result)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 160, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\jupyter_client\manager.py", line 259, in start_kernel
    **kw)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\jupyter_client\manager.py", line 204, in _launch_kernel
    return launch_kernel(kernel_cmd, **kw)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\site-packages\jupyter_client\launcher.py", line 128, in launch_kernel
    proc = Popen(cmd, **kwargs)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\subprocess.py", line 756, in __init__
    restore_signals, start_new_session)
  File "C:\Users\mct217\AppData\Local\Continuum\anaconda3\envs\PhD\lib\subprocess.py", line 1155, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

I just did the following:

A) Clean reinstall of Anaconda3-5.3.0 (python 3.7) on my Windows 10 desktop
B) Execute the following commands (exclude # and whatever comes after it) from the Anaconda prompt in the base environment

  1. conda update conda # was up to date anyway, so redundant
  2. conda update Anaconda # was up to date anyway, so redundant
  3. conda update --all # updates a few packages
  4. conda update -c defaults - c conda-forge ipykernel # updates to ipykernel 5.1.0 or whatever is current
  5. jupyter notebook your_notebook_name.ipynb --debug

I did not get any errors and the notebook did not skip cells upon execution.

If reinstall is not a problem, could you try this out ? Otherwise, make a new environment and try steps (3?), 4 and 5 from it

There may be a bit more than simply upgrading to 5.1. Installed 5.1 from forge, and I still run into the skip cell bug.

image
image

I have tried at least 5 clean Anaconda re-installs on my windows desktop and each time the skip cell problem in Jupyter notebooks was fixed by upgrading ipykernel. However, I suspect that something else may be wrong. I have an open issues thread related to a post-ipykernel upgrade problem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arbaazsama picture arbaazsama  路  3Comments

cancan101 picture cancan101  路  3Comments

harshinielath picture harshinielath  路  3Comments

uolter picture uolter  路  3Comments

itoed picture itoed  路  3Comments