Jupyter Notebook 'zmq message arrived on closed channel' Error

I am also experiencing this on my M1 Mac with jupyter_client 8.0.3 and tornado 6.2. Downgrading to tornado 6.1 seems to have fixed it.

I had the same issue with %matplotlib notebook. Using %matplotlib inline (or others) resolved the issue. Reverting to tornado==6.1 did not work for me.

Same problem as everyone else. I did install jupyterlab, in addition to jupyter, but it made no difference.

I had same problem. After investigation, I found the following warning in the beginning of the logs of my vscode jupyter notebook :

warn 13:04:52.769: Exception while attempting zmq : /snap/core/current/usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /home/mustapha/.vscode/extensions/ms-toolsai.jupyter-2023.2.1200692131/out/node_modules/zeromq/prebuilds/linux-x64/electron.napi.glibc.node)

I solved the problem sofar by installing ZMQ with apt : apt-get install libzmq3-dev and uninstalling vscode from snap and install it with apt like here https://code.visualstudio.com/docs/setup/linux . The snap libstdc++.so.6 package doesn’t contain last version of GLIBCXX even after update.

So far, I don’t get the warning above and all runs correctly

3 Likes

This bit solved it for me:

pip install --upgrade "pyzmq<25" "jupyter_client<8"
1 Like

I ran into this issue during development of a reactive Python kernel I work on called ipyflow. I did some digging here, and at least for me, it seems like this bug was introduced when the utility function run_sync was rewritten to no longer use nest_asyncio: Jupyter Notebook ‘zmq message arrived on closed channel’ Error · Issue #6721 · jupyter/notebook · GitHub

The run_sync function was moved from jupyter_client to jupyter_core recently, so fixing this bug will require a PR to jupyter_core.

In the meantime, to work around the current issue of zmq message arrived on closed channel, I ended up writing a server for ipyflow that monkey patches _TaskRunner.run in jupyter_core.utils to use the original nest_asyncio approach.

For folks that were able to resolve the issue by pinning jupyter_client, you may be able to also work around the issue without pinning by installing ipyflow (regardless of whether you use the ipyflow kernel or ipykernel), but obviously it’s not a long term fix:

pip install --upgrade ipyflow jupyter_client jupyter_server jupyter_core tornado

I am using docker jupyter: docker run --gpus all -p 8888:8888 tensorflow/tensofrflow:latest-gpu-jupyter

How to downgrad tornado for my case? I am new to tf jupyter docker…

Running the command @vasily mentioned did not solve it for me.
Downgrading to tornado==6.1 and/or jupyter-client==7.3.2 also didn’t fix the problem.
Using “%matplotlib inline” or “%matplotlib notebook” doesn’t make the error go away.

Problem occurs whenever I try to move a basic slider widget:

import ipywidgets as widgets

@widgets.interact
def f(x=5):
    print(x)

Other examples from the ipywidgets docs fail with the same error message.

To me, this issue only occurs when running my notebook with

%load_ext autoreload
%autoreload 2

I have a lot of cells and it almost always happens running the execute all cells above command but less often when running them one by one, waiting for the prior cell to finish before sending the execute command for the next cell.