title: AttributeError: module 'asyncio' has no attribute 'create_task'
body: <p>I'm trying to <code>asyncio.create_task()</code> but I'm dealing with this error:</p>
  <p>Here's an example:</p>
  <pre><code>import asyncio
  import time
  
  async def async_say(delay, msg):
      await asyncio.sleep(delay)
      print(msg)
  
  async def main():
      task1 = asyncio.create_task(async_say(4, 'hello'))
      task2 = asyncio.create_task(async_say(6, 'world'))
  
      print(f&quot;started at {time.strftime('%X')}&quot;)
      await task1
      await task2
      print(f&quot;finished at {time.strftime('%X')}&quot;)
  
  loop = asyncio.get_event_loop()
  loop.run_until_complete(main())
  </code></pre>
  <p>Out:</p>
  <pre><code>AttributeError: module 'asyncio' has no attribute 'create_task'
  </code></pre>
  <hr />
  <p>So I tried with the following code snippet (<code>.ensure_future()</code>) instead, without any problem:</p>
  <pre><code>async def main():
      task1 = asyncio.ensure_future(async_say(4, 'hello'))
      task2 = asyncio.ensure_future(async_say(6, 'world'))
  
      print(f&quot;started at {time.strftime('%X')}&quot;)
      await task1
      await task2
      print(f&quot;finished at {time.strftime('%X')}&quot;)
  
  loop = asyncio.get_event_loop()
  loop.run_until_complete(main())
  </code></pre>
  <p>Out:</p>
  <pre><code>started at 13:19:44
  hello
  world
  finished at 13:19:50
  </code></pre>
  <hr />
  <h1>What's wrong?</h1>
  <hr />
  <p>[<strong>NOTE</strong>]:</p>
  <ul>
  <li><em>Python 3.6</em></li>
  <li><em>Ubuntu 16.04</em></li>
  </ul>
  <hr />
  <p>[UPDATE]:</p>
  <p>With borrowing from <sub>@<a href="https://stackoverflow.com/users/1600898/user4815162342">user4815162342</a></sub> <a href="https://stackoverflow.com/a/53247626/3702377">Answer</a>, my problem solved:</p>
  <pre><code>async def main():
      loop = asyncio.get_event_loop()
      task1 = loop.create_task(async_say(4, 'hello'))
      task2 = loop.create_task(async_say(6, 'world'))
  
      print(f&quot;started at {time.strftime('%X')}&quot;)
      await task1
      await task2
      print(f&quot;finished at {time.strftime('%X')}&quot;)
  
  loop = asyncio.get_event_loop()
  loop.run_until_complete(main())
  </code></pre>