title: WinPython: "NameError: name 'time' is not defined", but only inside a function
body: <p>I'm using WinPython to run my Python program using a USB flash drive.
  But when I try to run an imported function inside a function I created, I receive the following error (it happens with any imported module):</p>
  <blockquote>
  <p>NameError: name 'time' is not defined</p>
  </blockquote>
  <p>Here is an example that works fine:</p>
  <pre><code>import time
  time.sleep(0.5)
  </code></pre>
  <p>Here is an example that doesn't work:</p>
  <pre><code>import time
  def waitLoad():
      time.sleep(0.2)
  waitLoad()
  </code></pre>
  <p>I receive the following error executing the example above:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;E:\WinPython\python-3.6.5.amd64\lib\runpy.py&quot;, line 193, in _run_module_as_main
      &quot;__main__&quot;, mod_spec)
    File &quot;E:\WinPython\python-3.6.5.amd64\lib\runpy.py&quot;, line 85, in _run_code
      exec(code, run_globals)
    File &quot;E:\WinPython\python-3.6.5.amd64\scripts\ptpython.exe\__main__.py&quot;, line 9, in &lt;module&gt;
    File &quot;E:\WinPython\python-3.6.5.amd64\lib\site-packages\ptpython\entry_points\run_ptpython.py&quot;, line 55, in run
      six.exec_(compile(open(a['&lt;arg&gt;'][0], &quot;rb&quot;).read(), a['&lt;arg&gt;'][0], 'exec'))
    File &quot;../testeMouse.py&quot;, line 4, in &lt;module&gt;
      waitLoad()
    File &quot;../testeMouse.py&quot;, line 3, in waitLoad
      time.sleep(0.2)
  NameError: name 'time' is not defined
  </code></pre>
  <p>If I execute the same program using the Python interpreter installed in my computer, the program works fine. But I need to execute it using the Python interpreter installed in my USB flash drive.</p>