question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on nest_asyncio.apply()

See original GitHub issue

Problem 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ccordoba12commented, May 15, 2022

Nop, we don’t have any control over that.

I’m going to close this issue because the bug is solved on our side.

0reactions
jhogg11commented, May 23, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found