title: Programmatically importing module via importlib - __path__ not set?
body: <p>I'm trying to import a sub-module programmatically. My file tree looks like this:</p>
  
  <pre><code>oopsd/__init__.py
  oopsd/oopsd.py
  oopsd/driver/__init__.py
  oopsd/driver/optiups.py
  </code></pre>
  
  <p>The optiups.py simply prints "Hello World".</p>
  
  <p>The oopsd.py looks like this:</p>
  
  <pre class="lang-python prettyprint-override"><code>import importlib
  importlib.import_module('oopsd.driver.optiups')
  </code></pre>
  
  <p>Now with this, I'm getting this exception:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;frozen importlib._bootstrap&gt;", line 1521, in _find_and_load_unlocked
  AttributeError: 'module' object has no attribute '__path__'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File "oopsd/oopsd.py", line 29, in &lt;module&gt;
      sys.exit(main())
    File "oopsd/oopsd.py", line 23, in main
      loaddriver()
    File "oopsd/oopsd.py", line 26, in loaddriver
      importlib.import_module('oopsd.driver.optiups')
    File "/usr/lib/python3.3/importlib/__init__.py", line 90, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 1586, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 1567, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 1514, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 313, in _call_with_frames_removed
    File "&lt;frozen importlib._bootstrap&gt;", line 1586, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 1567, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 1524, in _find_and_load_unlocked
  ImportError: No module named 'oopsd.driver'; oopsd is not a package
  </code></pre>
  
  <p>Does <code>__path__</code> even still exist in Python 3?</p>
  
  <p>I also tried importing <code>.driver.optiups</code> instead, but this yields:</p>
  
  <pre><code>TypeError: relative imports require the 'package' argument
  </code></pre>
  
  <p><code>__package__</code> seems unset, so I'm lost.</p>
  
  <p>How do I do this the right way?</p>