title: "ImportError: No module named _SHA256" when using PHP's exec() to call python script
body: <p>I have written a python script "thescript.py" that imports "SHA256.py", both of which are in the same directory "/thedirectory/include/".</p>
  
  <p>In PHP I do:</p>
  
  <pre><code>chdir('/thedirectory/include/');
  $result = exec('thescript.py argument1 2&gt;&amp;1');
  </code></pre>
  
  <p>Which gives me the result:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   File "thescript.py",
    line 4, in ?
        import SHA256   File "/thedirectory/include/SHA256.py", line 152, in ?
        import _SHA256 ImportError: No module named _SHA25</p>
  </blockquote>
  
  <p>The SHA256.py lines that cause this error are here:</p>
  
  <pre><code>try:
      import hashlib
      hashFactory = hashlib.sha256
  except ImportError:
      #from Crypto.Hash import _SHA256
      import _SHA256  # &lt;--- ERROR IS OCCURRING ON THIS LINE
      hashFactory = _SHA256
  </code></pre>
  
  <p>If I run this from the command line via SSH it runs fine. Why can't it import _SHA256?</p>
  
  <p>To be honest I don't understand what the underscore before the package name is even doing.</p>
  
  <p>Is the line <code>import _SHA256</code> in "SHA256.py" importing itself, or something?</p>