jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.71k stars 4.95k forks source link

Jupyter Notebook fails to run code with OSError and RunTimeError. #7433

Open appleplectic opened 3 months ago

appleplectic commented 3 months ago

Description

Cannot run any code through the web interface or third party interfaces like PyCharm - errors with OSError: [WinError 10038] An operation was attempted on something that is not a socket and RuntimeError: Event loop is closed.

Reproduce

Run jupyter notebook Open the link and create a new notebook. Run print("Hello") image

Expected behavior

Prints "hello"

Context

Troubleshoot Output
$PATH:
        C:\Program Files\PowerShell\7
        C:\Program Files\ImageMagick-7.1.1-Q16-HDRI
        C:\Program Files\Python312\Scripts\
        C:\Program Files\Python312\
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\bin
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.3\libnvvp
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\libnvvp
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\bin
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2\libnvvp
        C:\Program Files\Common Files\Oracle\Java\javapath
        C:\Program Files (x86)\Common Files\Oracle\Java\javapath
        C:\Program Files\Oculus\Support\oculus-runtime
        C:\WINDOWS\system32
        C:\WINDOWS
        C:\WINDOWS\System32\Wbem
        C:\WINDOWS\System32\WindowsPowerShell\v1.0\
        C:\WINDOWS\System32\OpenSSH\
        C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
        C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
        C:\Program Files\Git\cmd
        C:\Program Files\Git\mingw64\bin
        C:\Program Files\Git\usr\bin
        C:\Program Files\dotnet\
        C:\Program Files (x86)\Gpg4win\..\GnuPG\bin
        C:\Program Files\nodejs\
        C:\Program Files\WireGuard\
        C:\msys64\mingw64\bin\
        C:\ViVeTool
        C:\Users\llmar\flutter\bin
        C:\Program Files\Liquid Technologies\Liquid Studio\XmlDataBinder20\Redist20\cpp\win32\bin
        C:\Program Files\Liquid Technologies\Liquid Studio\XmlDataBinder20\Redist20\cpp\win64\bin
        C:\Program Files\PuTTY\
        C:\Program Files\Go\bin
        C:\Program Files\Crucial\Crucial Storage Executive
        C:\Program Files\Docker\Docker\resources\bin
        C:\Program Files\NVIDIA Corporation\Nsight Compute 2023.3.1\
        C:\Program Files\gnuplot\bin
        C:\Program Files\CMake\bin
        C:\Program Files\LLVM-bin\bin
        C:\cygwin64\bin
        C:\Program Files\PowerShell\7\
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Scripts\
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\
        C:\Users\llmar\AppData\Local\Programs\Python\Launcher\
        C:\Users\llmar\scoop\shims
        C:\Users\llmar\.cargo\bin
        C:\Users\llmar\AppData\Local\Programs\Microsoft VS Code\bin
        C:\Users\llmar\AppData\Local\Programs\Python\Python311\Scripts
        C:\Users\llmar\AppData\Local\Programs\Python\Python311
        C:\Users\llmar\AppData\Local\Microsoft\WindowsApps
        C:\Program Files\Common Files\Oracle\Java\javapath
        C:\Program Files\JetBrains\IntelliJ IDEA 2022.3.3\bin
        C:\Program Files\JetBrains\PyCharm 2022.3.3\bin
        C:\Program Files\JetBrains\CLion 2022.3.3\bin
        C:\Program Files\apache-maven-3.9.1\bin
        C:\Program Files\gradle-8.0.2\bin
        C:\Users\llmar\AppData\Roaming\Python\Scripts
        C:\Program Files\JetBrains\WebStorm 2023.1\bin
        C:\Users\llmar\AppData\Local\JetBrains\Toolbox\scripts
        C:\Users\llmar\AppData\Roaming\npm
        C:\msys64\mingw64\bin\
        C:\ViVeTool
        C:\Users\llmar\flutter\bin
        C:\Users\llmar\AppData\Local\spicetify
        C:\Users\llmar\.dotnet\tools
        C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\Hostx64\x64
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin
        C:\Users\llmar\go\bin
        C:\Users\llmar\AppData\Roaming\Python\Python311\Scripts
        C:\Users\llmar\AppData\Local\Microsoft\WinGet\Packages\nektos.act_Microsoft.Winget.Source_8wekyb3d8bbwe
        C:\Program Files\Java\bin
        C:\Users\llmar\AppData\Local\GitHubDesktop\bin
        C:\Program Files\Neovim\bin

sys.path:
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Scripts\jupyter-troubleshoot.EXE
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\python312.zip
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\DLLs
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib
        C:\Users\llmar\AppData\Local\Programs\Python\Python312
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32\lib
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\Pythonwin

sys.executable:
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\python.exe

sys.version:
        3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]

platform.platform():
        Windows-11-10.0.22631-SP0

where jupyter:
        C:\Users\llmar\AppData\Local\Programs\Python\Python312\Scripts\jupyter.exe
        C:\Users\llmar\AppData\Roaming\Python\Python311\Scripts\jupyter.exe

pip list:
        Package                   Version
        ------------------------- --------------
        anyio                     4.4.0
        argon2-cffi               23.1.0
        argon2-cffi-bindings      21.2.0
        arrow                     1.3.0
        asttokens                 2.4.1
        async-lru                 2.0.4
        attrs                     23.2.0
        Babel                     2.15.0
        beautifulsoup4            4.12.3
        bleach                    6.1.0
        certifi                   2024.7.4
        cffi                      1.16.0
        charset-normalizer        3.3.2
        colorama                  0.4.6
        comm                      0.2.2
        debugpy                   1.8.2
        decorator                 5.1.1
        defusedxml                0.7.1
        executing                 2.0.1
        fastjsonschema            2.20.0
        fqdn                      1.5.1
        h11                       0.14.0
        httpcore                  1.0.5
        httpx                     0.27.0
        idna                      3.7
        ipykernel                 6.29.5
        ipython                   8.26.0
        ipywidgets                8.1.3
        isoduration               20.11.0
        jedi                      0.19.1
        Jinja2                    3.1.4
        json5                     0.9.25
        jsonpointer               3.0.0
        jsonschema                4.23.0
        jsonschema-specifications 2023.12.1
        jupyter                   1.0.0
        jupyter_client            8.6.2
        jupyter-console           6.6.3
        jupyter_core              5.7.2
        jupyter-events            0.10.0
        jupyter-lsp               2.2.5
        jupyter_server            2.14.2
        jupyter_server_terminals  0.5.3
        jupyterlab                4.2.4
        jupyterlab_pygments       0.3.0
        jupyterlab_server         2.27.3
        jupyterlab_widgets        3.0.11
        MarkupSafe                2.1.5
        matplotlib-inline         0.1.7
        mistune                   3.0.2
        nbclient                  0.10.0
        nbconvert                 7.16.4
        nbformat                  5.10.4
        nest-asyncio              1.6.0
        notebook                  7.2.1
        notebook_shim             0.2.4
        overrides                 7.7.0
        packaging                 24.1
        pandocfilters             1.5.1
        parso                     0.8.4
        pip                       24.2
        pip-review                1.3.0
        platformdirs              4.2.2
        prometheus_client         0.20.0
        prompt_toolkit            3.0.47
        psutil                    6.0.0
        pure_eval                 0.2.3
        pycparser                 2.22
        Pygments                  2.18.0
        python-dateutil           2.9.0.post0
        python-json-logger        2.0.7
        pywin32                   306
        pywinpty                  2.0.13
        PyYAML                    6.0.1
        pyzmq                     26.0.3
        qtconsole                 5.5.2
        QtPy                      2.4.1
        referencing               0.35.1
        requests                  2.32.3
        rfc3339-validator         0.1.4
        rfc3986-validator         0.1.1
        rpds-py                   0.19.1
        Send2Trash                1.8.3
        setuptools                72.1.0
        six                       1.16.0
        sniffio                   1.3.1
        soupsieve                 2.5
        stack-data                0.6.3
        terminado                 0.18.1
        tinycss2                  1.3.0
        tornado                   6.4.1
        traitlets                 5.14.3
        types-python-dateutil     2.9.0.20240316
        uri-template              1.3.0
        urllib3                   2.2.2
        wcwidth                   0.2.13
        webcolors                 24.6.0
        webencodings              0.5.1
        websocket-client          1.8.0
        widgetsnbextension        4.0.11
Command Line Output
Exception in thread IOPub:
Traceback (most recent call last):
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1010, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
    self.io_loop.run_sync(_start_event_gc)
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\tornado\ioloop.py", line 533, in run_sync
    self.start()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\tornado\platform\asyncio.py", line 205, in start
    self.asyncio_loop.run_forever()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 641, in run_forever
    self._run_once()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1949, in _run_once
    event_list = self._selector.select(timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\selectors.py", line 323, in select
    r, w, _ = self._select(self._readers, self._writers, [], timeout)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\selectors.py", line 314, in _select
    r, w, x = select.select(r, w, w, timeout)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Traceback (most recent call last):
  File "", line 198, in _run_module_as_main
  File "", line 88, in _run_code
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\ipykernel_launcher.py", line 18, in 
    app.launch_new_instance()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\traitlets\config\application.py", line 1075, in launch_instance
    app.start()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\ipykernel\kernelapp.py", line 726, in start
    self.kernel.start()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\ipykernel\ipkernel.py", line 240, in start
    super().start()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\site-packages\ipykernel\kernelbase.py", line 583, in start
    asyncio.run_coroutine_threadsafe(self.poll_control_queue(), control_loop.asyncio_loop)
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\asyncio\tasks.py", line 950, in run_coroutine_threadsafe
    loop.call_soon_threadsafe(callback)
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 840, in call_soon_threadsafe
    self._check_closed()
  File "C:\Users\llmar\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 541, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
IOStream.flush timed out
Eyobs-droid commented 3 months ago

OSError: [WinError 10038] is occasionally caused by firewalls or network policies that might disrupt socket operations. Check the firewall settings to allow jupyter to establish connections properly.

Based on the research i did on reddit, the cause and how to solve the runtime error

RuntimeError: Event loop is closed often arises in asynchronous contexts particularly around asyncio and other event-driven libraries. So try these approaches:

  1. Ensure compatibulity of packages: Make sure your ipykernel, jupyter and any async libraries like aiohttp are upto date. "pip install --upgrade jupyter ipykernel aiohttp"
    1. Check Event loop policy: On windows, you might need to set the following before running async code. To do this: import asyncio asyncio.set_event_loop_policy(asyncio.WindowSelectorEventLoopPolicy())
    2. Directly running Asynchronous Code: "If you are running asynchronous tasks directly only" import asyncio async def main(): your code goes here asyncio.run(main())
appleplectic commented 3 months ago

Hi, appreciate the response.

Regarding the OSError, the firewall doesn't seem to be the problem - disabling all Windows firewalls did not resolve the issue.

On the RuntimeError: all packages are up to date, and I will try later inserting the event loop policy code but that will probably require a complete rebuild of jupyter.

I also tried a complete purge and reinstall of all Python and associated folders, and tried installing with conda, but errors persist.

Strangely, the errors only happen about 70% of the time - restarting the server multiple times sometimes results in no errors, and sometimes the server completely shuts down while other times it remains open. Other errors I am seeing are 404 errors where it cannot find the kernel, but again, this only happens occasionally and not all the time.

Full shutdown (crashes completely and stops server, 2x OSError, no firewall):

Exception in thread IOPub:
Traceback (most recent call last):
  File "C:\Users\llmar\miniforge3\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\llmar\miniforge3\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
    self.io_loop.run_sync(_start_event_gc)
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\ioloop.py", line 533, in run_sync
    self.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
    self.asyncio_loop.run_forever()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
    event_list = self._selector.select(timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
    r, w, _ = self._select(self._readers, self._writers, [], timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
    r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
[I 2024-08-04 12:08:42.816 ServerApp] Connecting to kernel a7ea2783-5731-4603-8eb5-7366dfd181cd.
Traceback (most recent call last):
  File "C:\Users\llmar\miniforge3\Scripts\jupyter-lab-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\extension\application.py", line 623, in launch_instance
    serverapp.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\serverapp.py", line 3121, in start
    self.start_ioloop()
  File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\serverapp.py", line 3107, in start_ioloop
    self.io_loop.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
    self.asyncio_loop.run_forever()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
    event_list = self._selector.select(timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
    r, w, _ = self._select(self._readers, self._writers, [], timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
    r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
[IPKernelApp] WARNING | Parent appears to have exited, shutting down.

Partial shutdown (OSError and RuntimeError, doesn't completely crash but doesn't run any code, shows [*], no firewall):

Exception in thread IOPub:
Traceback (most recent call last):
  File "C:\Users\llmar\miniforge3\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\llmar\miniforge3\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
    self.io_loop.run_sync(_start_event_gc)
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\ioloop.py", line 533, in run_sync
    self.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
    self.asyncio_loop.run_forever()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
    event_list = self._selector.select(timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
    r, w, _ = self._select(self._readers, self._writers, [], timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
    r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Traceback (most recent call last):
  File "C:\Users\llmar\miniforge3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\llmar\miniforge3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel_launcher.py", line 18, in <module>
    app.launch_new_instance()
  File "C:\Users\llmar\miniforge3\lib\site-packages\traitlets\config\application.py", line 1075, in launch_instance
    app.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelapp.py", line 726, in start
    self.kernel.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\ipkernel.py", line 240, in start
    super().start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelbase.py", line 583, in start
    asyncio.run_coroutine_threadsafe(self.poll_control_queue(), control_loop.asyncio_loop)
  File "C:\Users\llmar\miniforge3\lib\asyncio\tasks.py", line 892, in run_coroutine_threadsafe
    loop.call_soon_threadsafe(callback)
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 798, in call_soon_threadsafe
    self._check_closed()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
appleplectic commented 3 months ago

Tried to use a clean venv as well; still doesn't work.

Workaround for now is to restart the server around ~4 times until it works for some reason.

RRosio commented 2 months ago

Hi @appleplectic, just as with #7432, could you please try the fix that people found in https://github.com/jupyter/notebook/issues/5435?

appleplectic commented 2 months ago

Thanks for the response. Unfortunately, it doesn't work:

C:\Users\llmar\.jupyter\jupyter_notebook_config.py:

c = get_config()
c.NotebookApp.ip = "127.0.0.1"

(Didn't find c.NotebookApp.ip to uncomment; tried c.ServerApp.ip as well)

Also tried 0.0.0.0 and localhost - still does not work.

Error:

Exception in thread IOPub:
Traceback (most recent call last):
  File "C:\Users\llmar\miniforge3\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Users\llmar\miniforge3\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
    self.io_loop.run_sync(_start_event_gc)
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\ioloop.py", line 533, in run_sync
    self.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
    self.asyncio_loop.run_forever()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
    event_list = self._selector.select(timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
    r, w, _ = self._select(self._readers, self._writers, [], timeout)
  File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
    r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Traceback (most recent call last):
  File "C:\Users\llmar\miniforge3\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\llmar\miniforge3\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel_launcher.py", line 18, in <module>
    app.launch_new_instance()
  File "C:\Users\llmar\miniforge3\lib\site-packages\traitlets\config\application.py", line 1075, in launch_instance
    app.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelapp.py", line 726, in start
    self.kernel.start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\ipkernel.py", line 240, in start
    super().start()
  File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelbase.py", line 583, in start
    asyncio.run_coroutine_threadsafe(self.poll_control_queue(), control_loop.asyncio_loop)
  File "C:\Users\llmar\miniforge3\lib\asyncio\tasks.py", line 892, in run_coroutine_threadsafe
    loop.call_soon_threadsafe(callback)
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 798, in call_soon_threadsafe
    self._check_closed()
  File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 515, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
[W 2024-08-06 12:36:51.745 ServerApp] 404 GET /api/kernels/b0ef0033-9caf-4574-b4e3-133070df4e4b?1722962211741 (127.0.0.1): Kernel does not exist: b0ef0033-9caf-4574-b4e3-133070df4e4b
[W 2024-08-06 12:36:51.745 ServerApp] wrote error: 'Kernel does not exist: b0ef0033-9caf-4574-b4e3-133070df4e4b'
    Traceback (most recent call last):
      File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\web.py", line 1790, in _execute
        result = await result
      File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\auth\decorator.py", line 73, in inner
        return await out
      File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\services\kernels\handlers.py", line 75, in get
        model = await ensure_async(km.kernel_model(kernel_id))
      File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\services\kernels\kernelmanager.py", line 506, in kernel_model
        self._check_kernel_id(kernel_id)
      File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\services\kernels\kernelmanager.py", line 537, in _check_kernel_id
        raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
Eyobs-droid commented 2 months ago

try to uninstall and install pyzmq == 19.0.2 then restart the jupyter... if you encounter an error message "jupyter command not found" try reinstalling jupyter

appleplectic commented 2 months ago

It does appear to work after downgrading to Python 3.8, Jupyter Notebook 6.5.7, and pyzmq 19.0.2, although I do need newer versions of Python that won't be EOL'd in two months.

RRosio commented 2 months ago

Thank you for the updates @appleplectic, can try reproducing this error with Python 3.12 and the latest version of Notebook in a new conda environment.

appleplectic commented 2 months ago

Yes, the error is reproducible in a clean conda environment with Python 3.12.5 via conda and notebook 7.2.1.