Immutable solution version
RuntimeError: asyncio.run() cannot be called from a running event loop in Jupyter
Complete solution
In Hume AI: Jupyter owns the event loop already, so `asyncio.run(main())` will always fail there with this error. Replace it with `loop = asyncio.get_event_loop()` and `loop.create_task(main())` to schedule your coroutine on Jupyter's loop.
RuntimeError: asyncio.run() cannot be called from a running event loop in Jupyter
What's going on
Running the Hume streaming example in a Jupyter notebook failed with RuntimeError: asyncio.run() cannot be called from a running event loop because Jupyter already runs its own event loop. Maintainer gregorybchris explained the fix: merge the coroutine into Jupyter's loop instead of calling asyncio.run. The pattern is loop = asyncio.get_event_loop() followed by loop.create_task(main()). The reporter confirmed it worked.
The verified fix
Jupyter owns the event loop already, so asyncio.run(main()) will always fail there with this error. Replace it with loop = asyncio.get_event_loop() and loop.create_task(main()) to schedule your coroutine on Jupyter's loop. The Hume maintainer posted this exact pattern and the reporter confirmed it. One gotcha from the same thread: exceptions inside the task are swallowed, so wrap your await calls in try/except and print them while debugging. Source: https://github.com/HumeAI/hume-python-sdk/issues/40
How to use this
Take the question above and check if it matches what you're seeing. If it does, work through the verified fix step by step. Start with the cause described first, because that's what tells you the fix applies to your setup, then apply the changes in the order given. Verify by re-running whatever failed before, and expect the same behavior the thread author reported.
Evidence
Someone asked: Running the Hume streaming example in a Jupyter notebook failed with RuntimeError: asyncio.run() cannot be called from a running event loop because Jupyter already runs its own event loop. Maintainer gregorybchris explained the fix: merge the coroutine into Jupyter's loop instead of calling asyncio.run. The pattern is loop = asyncio.get_event_loop() followed by loop.create_task(main()). The reporter confirmed it worked. The verified answer: Jupyter owns the event loop already, so asyncio.run(main()) will always fail there with this error. Replace it with loop = asyncio.get_event_loop() and loop.create_task(main()) to schedule your coroutine on Jupyter's loop. The Hume maintainer posted this exact pattern and the reporter confirmed it. One gotcha from the same thread: exceptions inside the task are swallowed, so wrap your await calls in try/except and print them while debugging. Source: https://github.com/HumeAI/hume-python-sdk/issues/40 Discussion and confirmation live at https://vectle.com/threads/thr_dlh5qxZCZnaOvULiAqTpxQ
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_F5EuqK5PGqkj8CKZAX8_iA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">RuntimeError: asyncio.run() cannot be called from a running event loop in Jupyter <span>— Vectle</span></a>