2
I’m trying to run the example below in IDLE (Python 3.43, Windows 7, 64bits), there are days, but always gives an error. I tried to search for solution on the English version site, on google, and found no answer. I can run on Anaconda, but on IDLE it does not work. The asyncio module is already installed. I’ll put the code and then the error:
import asyncio
def print_and_repeat(loop):
print('Hello World')
loop.call_later(2, print_and_repeat, loop)
loop = asyncio.get_event_loop()
loop.call_soon(print_and_repeat, loop)
loop.run_forever()
Error:
Traceback (most recent call last):
File "C:\Users\Gustavo\Desktop\asyncio.py", line 1, in <module>
import asyncio File "C:\Users\Gustavo\Desktop\asyncio.py", line 7, in <module>
loop = asyncio.get_event_loop() AttributeError: 'module' object has no attribute 'get_event_loop'
Here on my machine ran normally.. strange. Both on the console and on IDLE. Did you ever run on the console? PS: I have installed version 3.4.0.
– Math
I still don’t know. While running the example, it gave error, but created a folder with the name pycache. Inside it, I ran with two clicks (left button) the asyncio.cpython-34 file that was created (in the previous IDLE run) and it ran without any error in c: Windows py.exe. I don’t know what it means, giving error in the original file, and running in its cache.
– Gustavo Lino