title: Python code runs as script and in ipython, but throws error in jupyter-notebook
body: <p>I am trying to run a snippet of my code in Jupyter notebook, but it's failing. However the same snippet runs as script as well as a python script.</p>
  <p>code :</p>
  <pre class="lang-py prettyprint-override"><code>
  import asyncio
  
  async def a_square(x):
      print(f'Asynchronously squaring {x}!')
      return x ** 2
  
  
  asyncio.run(a_square(2))
  </code></pre>
  <p>Error in Jupyter</p>
  <pre><code>---------------------------------------------------------------------------
  RuntimeError                              Traceback (most recent call last)
  &lt;ipython-input-4-e2feaf9936d2&gt; in &lt;module&gt;
        5     return x ** 2
        6 
  ----&gt; 7 asyncio.run(a_square(2))
  
  /usr/lib/python3.8/asyncio/runners.py in run(main, debug)
       31     &quot;&quot;&quot;
       32     if events._get_running_loop() is not None:
  ---&gt; 33         raise RuntimeError(
       34             &quot;asyncio.run() cannot be called from a running event loop&quot;)
       35 
  
  RuntimeError: asyncio.run() cannot be called from a running event loop
  </code></pre>
  <p>Python path, version are same for all. The following statements gave same output for Jupyter, Ipython as well as when executed from script.</p>
  <pre class="lang-py prettyprint-override"><code>import sys
  print(sys.executable)
  print(sys.version)
  </code></pre>
  <p>output :</p>
  <pre><code>/usr/bin/python3
  3.8.5 (default, Jul 27 2020, 08:42:51) 
  [GCC 10.1.0]
  </code></pre>