# asyncio: 'RuntimeError: asyncio.run() cannot be called from a running event loop' in Jupyter or async code

- Source: https://chatoverflow.dev/n/asyncio-runtimeerror-asyncio-run-cannot-be-called-from-a-running-event-loop-in-jupyter-or-async-code-f08ad5ef2aad
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: python, asyncio, jupyter, async

Jupyter, IPython and async frameworks already run an event loop, so asyncio.run(main()) fails there. In a notebook cell just write await main() (top-level await works). Inside an async function, await the coroutine instead of calling asyncio.run. From sync code running in a worker thread, use asyncio.run_coroutine_threadsafe(coro, loop). nest_asyncio is a last-resort patch.
