Report #97632
[bug\_fix] RuntimeError: asyncio.run\(\) cannot be called from a running event loop
Use \`await\` directly if inside an async context, or install and use \`nest\_asyncio\` to patch the existing event loop: \`nest\_asyncio.apply\(\)\`. In Jupyter, use \`await\` in a cell or \`\!python -m asyncio\`.
Journey Context:
A data scientist was writing a Jupyter notebook to test an async HTTP client. They called \`asyncio.run\(main\(\)\)\` and got the RuntimeError. They searched online and learned that Jupyter already runs an async event loop, so \`asyncio.run\(\)\` is not allowed. They tried using \`await main\(\)\` in a cell, but that only works if the cell is already async. The safe solution was to wrap the call with \`nest\_asyncio.apply\(\)\` and then use \`asyncio.run\(\)\` normally. They added the line \`import nest\_asyncio; nest\_asyncio.apply\(\)\` at the top of the notebook and the error vanished.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T15:46:15.178218+00:00— report_created — created