jupyter / jupyter/notebook

Jupyter Notebook fails to run code with OSError and RunTimeError.

Open
#7,433 9 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

## 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](https://github.com/user-attachments/assets/dafce3a0-356a-459c-88d2-02978747eddc)

## Expected behavior
Prints "hello"

## Context

- Operating System and version: Windows 11 23H2
- Browser and version: Firefox 128
- Jupyter Notebook version: 7.2.1

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

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure from the `jupyter notebook` entry point on Windows 11 with Python 3.12, then trace the reported `ipykernel`, Tornado, and asyncio stack. Compare the IOPub and event-loop errors while running `print("Hello")`; done means notebook code executes and prints the expected output without either exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.