title: Python CGI script - 500 error
body: <p>I have python CGI script that runs perfect on my local Apache 2.2.22 server. It outputs correct result and so on. But when I try to execute it on virtual hosting, there is error 500.
  I really have no idea why it does not works. </p>
  
  <p>Apache error log looks like:</p>
  
  <pre><code>[Wed Jul 12 16:06:54 2013] [error] [client 89.223.235.12] Premature end of script headers: /home/u67442/rrrrr.com/cgi-bin/test.py
  [Wed Jul 12 16:09:31 2013] [error] [client 89.223.235.12] Premature end of script headers: /home/u67442/rrrrr.com/cgi-bin/test.py
  </code></pre>
  
  <p>I've already tried following things:</p>
  
  <ol>
  <li>I'm sure that path to interpreter is correct - <code>#!/usr/local/bin/python</code>. Another CGI script works fine with this path.</li>
  <li>I have set chmod 755 to this script.</li>
  <li>I have set end-of-line characters in UNIX-format.</li>
  <li>I use correct HTTP-header: <code>print "Content-type:text/html\n\n"</code></li>
  </ol>
  
  <p>Output section of script:</p>
  
  <pre><code>    print "Content-type:text/html\n\n"
      print "&lt;html&gt;"
      print "&lt;head&gt;"
      print "&lt;title&gt;Results&lt;/title&gt;"
      print "&lt;head&gt;&lt;h2 align=center&gt;Results&lt;/h2&gt;&lt;/head&gt;"
      print "&lt;/head&gt;"
      print '&lt;body bgcolor="#e8f3d8"&gt;'
      print "&lt;hr&gt;"
      print "&lt;b&gt;Result = %s &lt;/b&gt;" % str(round(total_sum, 5))
      print "&lt;/body&gt;"
      print "&lt;/html&gt;" 
  </code></pre>
  
  <p>Funny that another VERY similar script with the same path, header, EOL, output and so on works perfect on local server and virtual hosting. And it's very strange that this script works fine on my local apache, but on virtual web hosting it crashes with 500 internal server error. I really don't know what to do. In technical support says that there is problem in my script.</p>
  
  <p>There is only one idea - timeout of waiting of output. Data processing in my script takes about 15-25 seconds.</p>
  
  <p>What can you advice?</p>