Error on nest_asyncio.apply()
See original GitHub issueProblem Description
I’m trying to set up a new Mac and get some existing projects running. Specifically, I’m trying to use nest_asyncio
in Spyder and getting an error on nest_asyncio.apply()
as well as inability to restart the kernel after applying.
What steps reproduce the problem?
import asyncio
import nest_asyncio
nest_asyncio.apply()
Paste Traceback/Error Below (if applicable)
And I get the following error message:
[SpyderKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/spyder_kernels/comms/frontendcomm.py", line 164, in poll_one
asyncio.run(handler(out_stream, ident, msg))
File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/nest_asyncio.py", line 33, in run
task = asyncio.ensure_future(main)
File "/Users/me/opt/anaconda3/lib/python3.9/asyncio/tasks.py", line 677, in ensure_future
raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
TypeError: An asyncio.Future, a coroutine or an awaitable is required
[SpyderKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/spyder_kernels/comms/frontendcomm.py", line 164, in poll_one
asyncio.run(handler(out_stream, ident, msg))
File "/Users/me/opt/anaconda3/lib/python3.9/site-packages/nest_asyncio.py", line 33, in run
task = asyncio.ensure_future(main)
File "/Users/me/opt/anaconda3/lib/python3.9/asyncio/tasks.py", line 677, in ensure_future
raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
TypeError: An asyncio.Future, a coroutine or an awaitable is required
The error appears to be unique to Spyder. I don’t see any errors when I run it in the terminal, Jupyter notebook, QT console, etc.
Versions
- Spyder version: 5.1.5
- Python version: 3.9.12
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
python - "RuntimeError: asyncio.run() cannot be called from a ...
It's a known problem related to IPython. One way as you already found is to use nest_asyncio : import nest_asyncio nest_asyncio.apply().
Read more >nest-asyncio - PyPI
pip install nest-asyncio ... Trying to do so will give the error “RuntimeError: This event loop is already ... import nest_asyncio nest_asyncio.apply().
Read more >[Fixed] ModuleNotFoundError: No module named 'nest-asyncio'
To fix this error, you can run the following command in your Windows shell:.
Read more >asyncio.run() cannot be called from a running event - You.com
Runtime error: asyncio.run cannot be called from running event loop ... I also tried to use nest_asyncio.apply() but it's show me the same...
Read more >nest-asyncio - Python Package Health Analysis - Snyk
Learn more about nest-asyncio: package health score, popularity, security, maintenance, versions and more. ... import nest_asyncio nest_asyncio.apply().
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Nop, we don’t have any control over that.
I’m going to close this issue because the bug is solved on our side.
Found the answer. Instead of installing
pyqtwebengine
through pip, it needed to be installed through conda-forge:conda install -c conda-forge pyqtwebengine
From one of the comments here: https://stackoverflow.com/questions/71580652/how-to-solve-error-while-installing-pyqtwebengine
@ccordoba12 - Thanks again for your help.