JupyterNotebook "stalling" on Macbook Air

Hi All,

I am using a Jupyter Notebook on Macbook Air, but constantly ruuning in to issues of notebook “stalling” after running a few cells. I am doing data analysis using Matplotlib, and it a simple code to plot the data. The same notebook (.ipynb) runs fine on the Windows but gets stuck when running on Macbook Air. Could you pleas ehelp me how to resolve this issue?

He is a list of errors I see in the Terminal.

“[E 14:30:55.952 NotebookApp] Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 584, in _run_callback
f = callback(*args, **kwargs)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 308, in stream_callback
return callback(self, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/services/kernels/handlers.py”, line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/base/zmqhandlers.py”, line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1056, in _write_frame
return self.stream.write(frame)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 539, in write
self._handle_write()
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 182, in advance
assert 0 < size <= self._size
AssertionError
[E 14:30:55.952 NotebookApp] Uncaught exception in zmqstream callback
Traceback (most recent call last):
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 634, in _handle_events
self._handle_recv()
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 663, in _handle_recv
self._run_callback(callback, msg)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 584, in _run_callback
f = callback(*args, **kwargs)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 308, in stream_callback
return callback(self, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/services/kernels/handlers.py”, line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/base/zmqhandlers.py”, line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1056, in _write_frame
return self.stream.write(frame)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 539, in write
self._handle_write()
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 182, in advance
assert 0 < size <= self._size
AssertionError
[E 14:30:55.953 NotebookApp] Exception in callback functools.partial(<function ZMQStream._update_handler.. at 0x1047c9700>)
Traceback (most recent call last):
File “/opt/homebrew/lib/python3.9/site-packages/tornado/ioloop.py”, line 738, in _run_callback
ret = callback()
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 718, in
self.io_loop.add_callback(lambda: self._handle_events(self.socket, 0))
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 634, in _handle_events
self._handle_recv()
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 663, in _handle_recv
self._run_callback(callback, msg)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 584, in _run_callback
f = callback(*args, **kwargs)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 308, in stream_callback
return callback(self, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/services/kernels/handlers.py”, line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/base/zmqhandlers.py”, line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1056, in _write_frame
return self.stream.write(frame)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 539, in write
self._handle_write()
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 182, in advance
assert 0 < size <= self._size
AssertionError”

I have tried updating/upgrading downgrading python/notebook and installed/reinstalled libraries etc., but none of that worked. Please let me know how can I get away with this?

Thanks,
Arslan

This isn’t accurate from what you post under, “He[sic] is a list of errors I see in the Terminal.”. Your title also isn’t accurate given that. It’s not ‘stalling’ after running a few cells. It’s encountering errors when it encounters specific code and exiting running. I’m pretty sure if you add more cells that don’t happen to have that specific code, such as simple math calculations, they’d probably continue to run. And so it isn’t that in general your Macbook is running a few cells and then quitting.

Why does that matter…Having a clear assessment of what is happening is important when trying to tease out what is going on. This notebook would probably not run fine on a Windows machine that had the same environment as your Macbook. This though is hard to 100% say because you aren’t allowing a clear assessment because you only really share the ‘effect’. You aren’t sharing any code so the ‘cause’ can be better examined. Now that may not be necessary here, but in general, it is better way to post asking for help. Anyway, I would think if you had a much more similar environment on each machine, you’d probably get the same result that you see. It isn’t a Windows vs. Macbook issue. Your Macbook seems to not have all the consistent packages necessary to run Jupyter. I wonder if as here you downgrade tornado or upgrade it, or upgrade ipykernel, if it will fix it. You may find more ideas on this forum or Stackoverflow if you search the specific start errors or the final ones you see. However, it may be easier at this point to switch to installing the Anaconda Distribution on your Macbook, and work in there and and see if it fixes things. If you do that, make sure you follow the ‘Getting Started’ Anaconda Distribution documentation exactly.

Hi,

Thanks for your quick reponse, and apologies for not being clear in the previous question. Jupyter Notebook runs the cells but when It comes to interacting plots, it stops workign and I see “buffering” sign in the Chrome tab, and nothing happens if i leave it like that until I restart the kernel/notebook, and it gets stuck there again. Please see the cause and erros below, and please let me know how can I resolve it?

-CAUSE-

#fig.subplots_adjust(top=5.85)

colormap = plt.colormaps.get_cmap(‘copper’)
cmap = plt.colormaps.get_cmap(‘viridis’)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(10, 4))

ax1.plot (T3, F3_3, label=‘3rd’, c=colormap(0.2))
ax1.plot (T3, F3_5, label=‘5th’, c=colormap(0.4))
ax1.plot (T3, F3_7, label=‘7th’, c=colormap(0.6))
ax1.plot (T3, F3_9, label=‘9th’, c=colormap(0.8))
ax1.plot (T3, F3_11, label=‘13th’, c=colormap(1.0))
#ax1.set_xlim (0, 32)
#ax.set_ylim (-8,0)

ax1twin = ax1.twinx()
ax1twin.plot (T3, D3_3, label=‘3rd D’, c=cmap(0.2))
ax1twin.plot (T3, D3_5, label=‘3rd D’, c=cmap(0.4))
ax1twin.plot (T3, D3_7, label=‘3rd D’, c=cmap(0.6))
ax1twin.plot (T3, D3_9, label=‘3rd D’, c=cmap(0.8))
ax1twin.plot (T3, D3_11, label=‘3rd D’, c=cmap(1.0))
#ax1twin.set_ylabel (‘Dissipation’, color = ‘r’)
#ax2.set_ylim (-0.2,2)

ax1.set_xlabel (‘Relative Time, min’)
ax1.set_ylabel (‘Relative Frequency, Hz’)
ax1twin.set_ylabel (‘Dissipation (x$10^{-6}$)’)

plt.subplots_adjust(wspace=0.5)

#ax1.legend ([‘3rd F’, ‘5th F’, ‘7th F’, ‘9th F’, ‘11th F’], frameon=False, loc=“center left”)
#ax1twin.legend ([‘3rd D’, ‘5th D’, ‘7th D’, ‘9th D’, ‘11th D’], frameon=False, loc=“center right”)

#2nd Subplot

ax2.plot (T3, F3_3, label=‘3rd’, c=colormap(0.2))
ax2.plot (T3, F3_5, label=‘5th’, c=colormap(0.4))
ax2.plot (T3, F3_7, label=‘7th’, c=colormap(0.6))
ax2.plot (T3, F3_9, label=‘9th’, c=colormap(0.8))
ax2.plot (T3, F3_11, label=‘13th’, c=colormap(1.0))
ax2.set_xlim (30, 55)
ax2.set_ylim (-100,0)

ax2twin = ax2.twinx()
ax2twin.plot (T3, D3_3, label=‘3rd D’, c=cmap(0.2))
ax2twin.plot (T3, D3_5, label=‘3rd D’, c=cmap(0.4))
ax2twin.plot (T3, D3_7, label=‘3rd D’, c=cmap(0.6))
ax2twin.plot (T3, D3_9, label=‘3rd D’, c=cmap(0.8))
ax2twin.plot (T3, D3_11, label=‘3rd D’, c=cmap(1.0))
#ax2twin.set_ylabel (‘Dissipation’, color = ‘r’)
ax2twin.set_ylim (0,20)
#ax2twin.set_ylim (-6, 60)

ax2.set_xlabel (‘Relative Time, min’)
ax2.set_ylabel (‘Relative Frequency, Hz’)
ax2twin.set_ylabel (‘Dissipation (x$10^{-6}$)’)

#Adjusting the colors of the y-ticks
#ax1.tick_params(axis=‘y’, colors=‘b’)
#ax2.tick_params(axis=‘y’, colors=‘b’)
#ax1twin.tick_params(axis=‘y’, colors=‘r’)
#ax2twin.tick_params(axis=‘y’, colors=‘r’)

#Adjusting the space between subplots
plt.subplots_adjust(wspace=0.5)

ax1.legend ([‘3rd F’, ‘5th F’, ‘7th F’, ‘9th F’, ‘11th F’], frameon=True, loc=“upper center”,
bbox_to_anchor=(0.5, 1.15), ncol=3, fontsize=‘small’)
ax2twin.legend ([‘3rd D’, ‘5th D’, ‘7th D’, ‘9th D’, ‘11th D’], frameon=True, loc=“upper center”,
bbox_to_anchor=(0.5, 1.15), ncol=3, fontsize=‘small’)
#fig.tight_layout(rect=[0, 0, 1, 0.9])

-ERRORS-

[E 14:37:21.161 NotebookApp] Uncaught exception in ZMQStream callback
Traceback (most recent call last):
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 584, in _run_callback
f = callback(*args, **kwargs)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 308, in stream_callback
return callback(self, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/services/kernels/handlers.py”, line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/base/zmqhandlers.py”, line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1056, in _write_frame
return self.stream.write(frame)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 539, in write
self._handle_write()
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 182, in advance
assert 0 < size <= self._size
AssertionError
[E 14:37:21.163 NotebookApp] Uncaught exception in zmqstream callback
Traceback (most recent call last):
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 634, in _handle_events
self._handle_recv()
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 663, in _handle_recv
self._run_callback(callback, msg)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 584, in _run_callback
f = callback(*args, **kwargs)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 308, in stream_callback
return callback(self, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/services/kernels/handlers.py”, line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/base/zmqhandlers.py”, line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1056, in _write_frame
return self.stream.write(frame)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 539, in write
self._handle_write()
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 182, in advance
assert 0 < size <= self._size
AssertionError
[E 14:37:21.166 NotebookApp] Exception in callback functools.partial(<function ZMQStream._update_handler.. at 0x106d1b550>)
Traceback (most recent call last):
File “/opt/homebrew/lib/python3.9/site-packages/tornado/ioloop.py”, line 738, in _run_callback
ret = callback()
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 718, in
self.io_loop.add_callback(lambda: self._handle_events(self.socket, 0))
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 634, in _handle_events
self._handle_recv()
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 663, in _handle_recv
self._run_callback(callback, msg)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 584, in _run_callback
f = callback(*args, **kwargs)
File “/opt/homebrew/lib/python3.9/site-packages/zmq/eventloop/zmqstream.py”, line 308, in stream_callback
return callback(self, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/services/kernels/handlers.py”, line 572, in _on_zmq_reply
super()._on_zmq_reply(stream, msg)
File “/opt/homebrew/lib/python3.9/site-packages/notebook/base/zmqhandlers.py”, line 256, in _on_zmq_reply
self.write_message(msg, binary=isinstance(msg, bytes))
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 334, in write_message
return self.ws_connection.write_message(message, binary=binary)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1081, in write_message
fut = self._write_frame(True, opcode, message, flags=flags)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/websocket.py”, line 1056, in _write_frame
return self.stream.write(frame)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 539, in write
self._handle_write()
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 965, in _handle_write
self._write_buffer.advance(num_bytes)
File “/opt/homebrew/lib/python3.9/site-packages/tornado/iostream.py”, line 182, in advance
assert 0 < size <= self._size
AssertionError

Please let me know what’s the issue, and how can I reoslve it?

Thanks,
Arslan

Did you try anything else from my last post other than running the same notebook again? It seems you have inconsistent/outdated versions as discussed in that link I referenced. A number of approaches to finding a solution were discussed there.

I have a similar but not identical situation on Windows 10. See Jupyter Notebook "stalling" on Windows 10

What version of tornado do you advise rolling back to?

There seems to be a longstanding issue Jupyter Notebook ‘zmq message arrived on closed channel’ Error · Issue #6721 · jupyter/notebook · GitHub & https://github.com/microsoft/vscode-jupyter/issues/12775

A common thread seems to downgrade jupyter_client to before 8.0.0
One suggests pip3.10 install IPython==8.4.0 ipykernel==6.15.2 ipywidgets==7.7.2 \ jupyter==1.0.0 jupyter_client==7.3.5 jupyter_core==4.12.0 jupyter-console==6.5.1 jupyter_server==1.21.0 \ nbclient==0.6.7 nbformat==5.4.0 notebook==6.4.12 traitlets==5.4.0 qtconsole==5.3.1

1 Like

The errors reported are in the console output - not the code.
There is a longstanding issue Jupyter Notebook ‘zmq message arrived on closed channel’ Error · Issue #6721 · jupyter/notebook · GitHub & https://github.com/microsoft/vscode-jupyter/issues/12775

This is the first Jupyter bug I have encountered. What happens to get it fixed?
I have downgraded jupyter_client - but since the error is intermittent, I can’t promise that is a viable workaround.