Python3.6 AttributeError: module 'asyncio' has no attribute 'run'
Full error message
I tried to read https://hackernoon.com/asynchronous-python-45df84b82434.
It's about asynchronous python and I tried the code from this, but I'm getting a weird Error.
The code is:
`
import asyncio
import aiohttp
urls = ['http://www.google.com', 'http://www.yandex.ru', 'http://www.python.org']
async def call_url(url):
print('Starting {}'.format(url))
response = await aiohttp.ClientSession().get(url)
data = await response.text()
print('{}: {} bytes: {}'.format(url, len(data), data))
return data
futures = [call_url(url) for url in urls]
asyncio.run(asyncio.wait(futures))
When I try to run it says:
Traceback (most recent call last):
File "test.py", line 15, in <module>
asyncio.run(asyncio.wait(futures))
AttributeError: module 'asyncio' has no attribute 'run'
sys:1: RuntimeWarning: coroutine 'call_url' was never awaited
I dont have any files named ayncio and I have proof:
>>> asyncio
<module 'asyncio' from '/usr/lib/python3.6/asyncio/__init__.py'>Solutionsource: stackoverflow \u2197
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))
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/c07f78e66b86fea603a0d44c0d2cfe38f57845e27c7200088a1e01f01cd425b8hash \u00b7 c07f78e66b86fea603a0d44c0d2cfe38f57845e27c7200088a1e01f01cd425b8