close

[Solved] Python3.6 AttributeError: module ‘asyncio’ has no attribute ‘run’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Python3.6 AttributeError: module ‘asyncio’ has no attribute ‘run’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Python3.6 AttributeError: module ‘asyncio’ has no attribute ‘run’ Error Occurs?

Today I get the following error Python3.6 AttributeError: module ‘asyncio’ has no attribute ‘run’ in python.

How To Solve Python3.6 AttributeError: module ‘asyncio’ has no attribute ‘run’ Error ?

  1. How To Solve Python3.6 AttributeError: module 'asyncio' has no attribute 'run' Error ?

    To Solve Python3.6 AttributeError: module 'asyncio' has no attribute 'run' Error Note the provisional part; the Python maintainers forsee that the function may need further tweaking and updating, so the API may change in future Python versions.

  2. Python3.6 AttributeError: module 'asyncio' has no attribute 'run'

    To Solve Python3.6 AttributeError: module 'asyncio' has no attribute 'run' Error Note the provisional part; the Python maintainers forsee that the function may need further tweaking and updating, so the API may change in future Python versions.

Solution 1

asyncio.run is a Python 3.7 addition. In 3.5-3.6, your example is roughly equivalent to:

import asyncio

futures = [...]
loop = asyncio.get_event_loop()
loop.run_until_complete(asyncio.wait(futures))

Solution 2

The asyncio.run() function was added in Python 3.7. From the asyncio.run() function documentation:

New in version 3.7: Important: this function has been added to asyncio in Python 3.7 on a provisional basis.

Note the provisional part; the Python maintainers forsee that the function may need further tweaking and updating, so the API may change in future Python versions.

At any rate, you can’t use it on Python 3.6. You’ll have to upgrade or implement your own.

A very simple approximation would be to use loop.run_until_complete():

loop = asyncio.get_event_loop()
result = loop.run_until_complete(coro)

although this ignores handling remaining tasks that may still be running. See the asyncio.runners source code for the complete asyncio.run() implementation.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read