Notebook takes a long time to start the kernel, but if restarted, it kicks in immediately

Something strange is happening with my notebooks and I’m not able to find the root cause. I’m using notebook==6.5.4.

When I start the server jupyter notebook (not lab), the kernel takes A LONG time to “start” (or at least, aknowledge it has started). It gets stuck in the “Kernel starting, please wait” message for at least 30 seconds.

BUT! If I start the server, the browser opens automatically, and I immediately restart the kernel (0 0), it just works! It takes no considerable time.

Do you know what might be the reason for this?

Update… I might have found a way to “fix” it, but I don’t know the reason.

Some time ago, I updated to nbclassic==0.5.6 and added the c.NotebookApp.show_banner = False config to turn off the Notebook 7 warning banner (related issue nbclassic#242).

That seems to have caused this issue (it’s the only thing I changed).

The way I “fixed” it was: instead of launching jupyter notebook, I launch jupyter nbclassic. And the kernel starts immediately.

Any ideas why? What am I doing wrong?

1 Like

I have noticed the same problem. I am on Mac OS 13.3.1 (a) on Apple M1.

Versions:

jupyter --version
Selected Jupyter core packages…
IPython : 8.13.2
ipykernel : 6.23.0
ipywidgets : 8.0.6
jupyter_client : 8.2.0
jupyter_core : 5.3.0
jupyter_server : 2.5.0
jupyterlab : not installed
nbclient : 0.7.4
nbconvert : 7.3.1
nbformat : 5.8.0
notebook : 6.5.4
qtconsole : 5.4.3
traitlets : 5.9.0

Here are my observations so far.

  1. The problem is seen in Safari browser version 16.4 not in Chrome Version 113.0.5672.126 (Official Build) (arm64).

  2. Kernel start is slow for both ipykernel and Octave meta-kernel.

  3. Debug output is

 jupyter notebook  --debug
[D 09:29:45.550 NotebookApp] Searching ['/Users/sunilshah/.jupyter', '/Users/sunilshah/Library/Python/3.11/etc/jupyter', '/usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/etc/jupyter', '/usr/local/etc/jupyter', '/etc/jupyter'] for config files
[D 09:29:45.551 NotebookApp] Looking for jupyter_config in /etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_config in /usr/local/etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_config in /usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_config in /Users/sunilshah/Library/Python/3.11/etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_config in /Users/sunilshah/.jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_notebook_config in /etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_notebook_config in /usr/local/etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_notebook_config in /usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_notebook_config in /Users/sunilshah/Library/Python/3.11/etc/jupyter
[D 09:29:45.551 NotebookApp] Looking for jupyter_notebook_config in /Users/sunilshah/.jupyter
[D 09:29:45.551 NotebookApp] Raising open file limit: soft 256->4096; hard 9223372036854775807->9223372036854775807
[D 09:29:45.578 NotebookApp] Paths used for configuration of jupyter_notebook_config: 
    	/etc/jupyter/jupyter_notebook_config.json
[D 09:29:45.578 NotebookApp] Paths used for configuration of jupyter_notebook_config: 
    	/usr/local/etc/jupyter/jupyter_notebook_config.json
[D 09:29:45.578 NotebookApp] Paths used for configuration of jupyter_notebook_config: 
    	/usr/local/opt/python@3.11/Frameworks/Python.framework/Versions/3.11/etc/jupyter/jupyter_notebook_config.json
[D 09:29:45.578 NotebookApp] Paths used for configuration of jupyter_notebook_config: 
    	/Users/sunilshah/Library/Python/3.11/etc/jupyter/jupyter_notebook_config.json
[D 09:29:45.578 NotebookApp] Paths used for configuration of jupyter_notebook_config: 
    	/Users/sunilshah/.jupyter/jupyter_notebook_config.json

...

[I 09:29:45.769 NotebookApp] Serving notebooks from local directory: /Users/sunilshah/Library/Mobile Documents/com~apple~CloudDocs/invest
[I 09:29:45.769 NotebookApp] Jupyter Notebook 6.5.4 is running at:
[I 09:29:45.769 NotebookApp] http://localhost:8888/?token=9e4c0f756da4763151b883d8ed0ba4d08cdcbbc9ed3b0b54
[I 09:29:45.769 NotebookApp]  or http://127.0.0.1:8888/?token=9e4c0f756da4763151b883d8ed0ba4d08cdcbbc9ed3b0b54
[I 09:29:45.769 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:29:45.778 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///Users/sunilshah/Library/Jupyter/runtime/nbserver-11502-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=9e4c0f756da4763151b883d8ed0ba4d08cdcbbc9ed3b0b54
     or http://127.0.0.1:8888/?token=9e4c0f756da4763151b883d8ed0ba4d08cdcbbc9ed3b0b54

...

[D 09:29:55.097 NotebookApp] Path components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js served from /usr/local/lib/python3.11/site-packages/nbclassic/static/components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js
[D 09:29:55.098 NotebookApp] 304 GET /static/components/MathJax/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js?V=2.7.9 (::1) 2.240000ms
[D 09:29:55.098 NotebookApp] Path jupyter-js-widgets/extension.js served from /usr/local/share/jupyter/nbextensions/jupyter-js-widgets/extension.js
[D 09:29:55.100 NotebookApp] 200 GET /nbextensions/jupyter-js-widgets/extension.js?v=20230520092945 (::1) 4.350000ms
[D 09:29:55.100 NotebookApp] Path components/MathJax/extensions/Safe.js served from /usr/local/lib/python3.11/site-packages/nbclassic/static/components/MathJax/extensions/Safe.js
[D 09:29:55.101 NotebookApp] 304 GET /static/components/MathJax/extensions/Safe.js?V=2.7.9 (::1) 4.970000ms
[D 09:29:55.102 NotebookApp] Initializing websocket connection /api/kernels/9a88614d-9bc1-4a09-ba89-b5e9d86ffe74/channels
[D 09:29:55.103 NotebookApp] Requesting kernel info from 9a88614d-9bc1-4a09-ba89-b5e9d86ffe74
[D 09:29:55.103 NotebookApp] Connecting to: tcp://127.0.0.1:50726
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[D 09:29:55.727 NotebookApp] activity on 9a88614d-9bc1-4a09-ba89-b5e9d86ffe74: status (busy)
[D 09:29:55.727 NotebookApp] activity on 9a88614d-9bc1-4a09-ba89-b5e9d86ffe74: status (idle)
[D 09:29:55.728 NotebookApp] Received kernel info: {'status': 'ok', 'protocol_version': '5.3', 'implementation': 'ipython', 'implementation_version': '8.13.2', 'language_info': {'name': 'python', 'version': '3.11.3', 'mimetype': 'text/x-python', 'codemirror_mode': {'name': 'ipython', 'version': 3}, 'pygments_lexer': 'ipython3', 'nbconvert_exporter': 'python', 'file_extension': '.py'}, 'banner': "Python 3.11.3 (main, Apr  7 2023, 19:25:52) [Clang 14.0.0 (clang-1400.0.29.202)]\nType 'copyright', 'credits' or 'license' for more information\nIPython 8.13.2 -- An enhanced Interactive Python. Type '?' for help.\n", 'help_links': [{'text': 'Python Reference', 'url': 'https://docs.python.org/3.11'}, {'text': 'IPython Reference', 'url': 'https://ipython.org/documentation.html'}, {'text': 'NumPy Reference', 'url': 'https://docs.scipy.org/doc/numpy/reference/'}, {'text': 'SciPy Reference', 'url': 'https://docs.scipy.org/doc/scipy/reference/'}, {'text': 'Matplotlib Reference', 'url': 'https://matplotlib.org/contents.html'}, {'text': 'SymPy Reference', 'url': 'http://docs.sympy.org/latest/index.html'}, {'text': 'pandas Reference', 'url': 'https://pandas.pydata.org/pandas-docs/stable/'}]}
[D 09:30:48.950 NotebookApp] 101 GET /api/kernels/9a88614d-9bc1-4a09-ba89-b5e9d86ffe74/channels?session_id=d74323ac385e40379ec9f914ae2acd79 (::1) 53848.730000ms
[D 09:30:48.951 NotebookApp] Opening websocket /api/kernels/9a88614d-9bc1-4a09-ba89-b5e9d86ffe74/channels