title: Very weird issue with import
body: <p>I'm hitting a very weird issue.</p>
  
  <p>Edit: Adding full details:</p>
  
  <pre><code>virtualenv -p python3 testenv
  cd testenv
  source bin/activate
  django-admin startproject blah
  cd blah
  mkdir modules
  vi modules/stash.py
  pip install django
  pip install stashy
  python manage.py shell &lt; modules/stash.py
  </code></pre>
  
  <p>I have a script that sync data to populate a database:</p>
  
  <pre><code>$ cat modules/stash.py
  import stashy
  class SyncProject:
      def __init__(self, endpo, user, passw):
          import stashy
          self.stash = stashy.connect(endpo, user, passw)
  
  access = SyncProject("http://localhost", "test", "test" )
  </code></pre>
  
  <p>I run my script with:</p>
  
  <pre><code>$ python  manage.py shell &lt; modules/stash.py
  </code></pre>
  
  <p>The weirdness is that if I don't put the second <code>import stashy</code>, it doesn't work:</p>
  
  <pre><code>NameError: name 'stashy' is not defined
  </code></pre>
  
  <p>From the bit of Python I did a long time ago, that seems very unexpected and forces me to add import in every single method... Not sure if there is something wrong in how I import my dependencies or the way I run the script...</p>
  
  <p>Edit: more details, the error message: </p>
  
  <pre><code>Traceback (most recent call last):
    File "manage.py", line 15, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/[PATH]/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
      utility.execute()
    File "/[PATH]/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/[PATH]/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/[PATH]/python3.6/site-packages/django/core/management/base.py", line 335, in execute
      output = self.handle(*args, **options)
    File "/[PATH]/python3.6/site-packages/django/core/management/commands/shell.py", line 92, in handle
      exec(sys.stdin.read())
    File "&lt;string&gt;", line 6, in &lt;module&gt;
    File "&lt;string&gt;", line 4, in __init__
  NameError: name 'stashy' is not defined
  </code></pre>