Getting python to work, Internal Server Error
<p>I'm trying to get Python scripts, called from a web browser, to work. I keep getting the error: </p>

<pre><code>500 Internal Server Error
</code></pre>

<p>When I check my error logs I see the message </p>

<pre><code>Premature end of script headers
</code></pre>

<p>The only documentation of this error online says that it can be the result of having improper line return characters in your script, but I wrote my test script right from the shell with pico. Also, when I run the file from the command line it executes just fine. 
"
So far the only change I have made to apache is to add the .py to the "AddHandler cgi-script" line.</p>

<p>Thanks!</p>

<hr>

<p>Thanks for the quick responses. Here is the latest version of the test code. I added a couple new lines before the output as suggested but still get the same error:</p>

<pre><code>#!/usr/local/bin/python
print "Content-type: text/html\n"
print "\n\n"
print "&lt;HTML&gt;"
print "&lt;HEAD&gt;"
print "&lt;TITLE&gt;Test&lt;/TITLE&gt;"
print "&lt;/HEAD&gt;"
print "&lt;BODY&gt;"
print "&lt;H2&gt;Hi there.&lt;/h2&gt;"
print "&lt;/BODY&gt;"
print "&lt;/HTML&gt;"
</code></pre>

<p>Some other details: I am running Apache 1.3 and don't have mod_python. I set apache to recognize .py as mentioned above. I am running the script from the main public_html folder. </p>

<hr>

<p>An update. It doesn't seem to matter what I put in the shebang line. I tried all of the suggestions and even if I leave it blank the same error is showing up in the errors log and I'm getting a 500 error. </p>

<p>I'm running Apache/1.3.41 on linux (red hat 3.4) with WHM/Cpanel installed.  </p>
