Issue
I am trying to run the below program using asyncio:
import asyncio
async def main():
print('Hello')
await asyncio.sleep(1)
print('World')
asyncio.run(main())
However, I am getting the following error:
AttributeError: module 'asyncio' has no attribute 'run'
python --version gives: Python 2.7.8
python3 --version gives: Python 3.7.1
I am running the script as python3 script.py
Any ideas on how can I run this program without any error?
Solution
My bet: your script.py
file actually has name asyncio.py
(or you have such file somewhere in PYTHONPATH
). Rename it to something different and everything will work.
Answered By - Mikhail Gerasimov
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.