title: Python relative imports with sys.path
body: <p>I have this weird Python import and I can't get it to work with any of the suggestions in other discussions.</p>
  
  <p>I'm currently adding a small script to someone else's module, so I cannot change the file structure or any of the existing code, which makes things difficult.</p>
  
  <p>Here is an example of the python script which contains a bunch of classes:</p>
  
  <pre><code>/path/to/root/directory/aaa/bbb/ccc/utils.py
  </code></pre>
  
  <p>The current developer imports this as follows:</p>
  
  <pre><code>from aaa.bbb.ccc import utils
  utils.SomeClass.someMethod()
  </code></pre>
  
  <p>All directories in the tree have a <code>__init__.py</code> file</p>
  
  <p>Now I want to call the module externally as follows:</p>
  
  <pre><code>import sys
  sys.path.append('/path/to/root/directory')
  from aaa.bbb.ccc import utils
  utils.SomeClass.someMethod()
  </code></pre>
  
  <p>This does NOT work, and gives the the following error:</p>
  
  <pre><code>from aaa.bbb.ccc import utils
  ImportError: No module named ccc
  </code></pre>
  
  <p>However, changing the import a little bit does work:</p>
  
  <pre><code>import sys
  sys.path.append('/path/to/root/directory')
  from aaa.bbb.ccc.utils import *
  SomeClass.someMethod()
  </code></pre>
  
  <p>I do not understand why the 2nd one works and not the 1st. Again, I cannot change the existing code, so the following 2 statements must work with my sys.path.append and imports:</p>
  
  <pre><code>from aaa.bbb.ccc import utils
  utils.SomeClass.someMethod()
  </code></pre>
  
  <p>I cannot remove the <code>utils</code> from <code>utils.SomeClass</code></p>
  
  <p>Does anyone know how I can achieve this?</p>