Install nest_asyncio via pip
masterInstall the nest_asyncio package using pip. This package requires Python 3.5 or higher.
pip3 install nest_asynciorepository·master·Indexed 20 days ago
https://github.com/erdewit/nest_asyncioA utility that patches the asyncio module to allow nested event loops, preventing 'RuntimeError: This event loop is already running' in environments where a loop is already active, such as Jupyter notebooks, web servers, or GUI applications. It enables nested use of asyncio.run and loop.run_until_complete via nest_asyncio.apply().
Install the nest_asyncio package using pip. This package requires Python 3.5 or higher.
pip3 install nest_asyncioBy default, asyncio does not allow its event loop to be nested, which causes a RuntimeError: This event loop is already running when attempting to run tasks in environments like Jupyter notebooks, web servers, or GUI applications.
nest_asyncio patches asyncio to allow nested use of asyncio.run and loop.run_until_complete.
To use it, call nest_asyncio.apply(). You can optionally pass a specific event loop as an argument to apply() to patch it; otherwise, the current event loop is used. Note that only asyncio event loops can be patched; loops from other projects like uvloop or quamash generally cannot be patched.
import nest_asyncio
nest_asyncio.apply()