title: How is the python module search path determined on Mac OS X?
body: <p>When a non built-in module is imported, the interpreter searches in the locations given by <code>sys.path</code>. <code>sys.path</code> is initialized from these locations (<a href="http://docs.python.org/library/sys.html#sys.path">http://docs.python.org/library/sys.html#sys.path</a>):</p>
  
  <ol>
  <li>the directory containing the input script (or the current directory)</li>
  <li>PYTHONPATH</li>
  <li>the installation-dependent default</li>
  </ol>
  
  <p>While the first two sources are straight-forward, can anyone explain how the third one works, and what possibilities there are for influencing it?</p>
  
  <p>Although I would be interested in a general solution, my specific issues are:</p>
  
  <ul>
  <li>I have installed the <a href="http://www.enthought.com/">Enthought distribution 7.2 32-bit</a>, and then <a href="http://fonnesbeck.github.com/ScipySuperpack/">Scipy-Superpack</a>. Now enthought python tries to import numpy from <code>/Library/Python/2.7/</code>, which is where superpack installed them, instead of from the enthought site-packages.</li>
  <li>a <code>wxPython</code> application created with <code>py2app</code> <code>-A</code> does not have the same <code>sys.path</code> as when starting the application with <code>python start_app.py</code>.  </li>
  </ul>