title: `Importlib` not actually importing modules?
body: <p>I'm trying run an <code>env_setup</code> script that imports modules used in my <code>main_script</code>. But despite successfully running <code>env_setup.py</code> the modules are not being imported (presumably it is being run in its own environment).</p>
  <p>Previously I know I have somehow sucesfully used:</p>
  <pre><code>from env_setup import *
  </code></pre>
  <p>However this fails for me now.</p>
  <p>I tried a second approach using:</p>
  <pre><code>importlib.util.spec_from_file_location(name, location)
  </code></pre>
  <p>But this also fails.</p>
  <p>Below is an example of what I am attempting (using the second approach in my <code>main_script.py</code>):</p>
  <p><strong>Example</strong> <code>env_setup.py</code> <strong>script</strong>:</p>
  <pre><code>import datetime # import module
  print(&quot;modules imported!!!&quot;) # confirm import
  </code></pre>
  <p><strong>Example</strong> <code>main_script.py</code> <strong>script</strong>:</p>
  <pre><code># This first section should import `datetime` using `env_setup.py`
  import importlib
  spec = importlib.util.spec_from_file_location(
         name='setup',
         location='/home/solebay/my project/env_setup.py' # path to `set_up` script
         )
  my_mod = importlib.util.module_from_spec(spec)
  spec.loader.exec_module(my_mod)
  # This returns &quot;modules imported!!!&quot;
  
  # Here we run a basic command to check if `datetime` was imported...
  now = datetime.datetime.now()
  print(now.strftime('%H:%M:%S on %A, %B the %dth, %Y')) # Should print time/date
  # NameError: name 'datetime' is not defined 
  </code></pre>
  <p>How do I get python to actually import the required modules into the environment running <code>main_script.py</code>? It creates a <code>__pycache__</code> folder so I know the path is correct.</p>