user3445138
user3445138

Reputation: 43

Error message: End of script output before headers

I have been trying to start using Python with Apache and have followed all of the tutorials that I could find online. There are others with this problem but I have been unable to solve it for myself. Apache runs Perl files successfully but not Python files. Instead I get the error above - End of script output before headers. I am pointing to the correct path to python.exe and have tried countless variations of the simple code that I am trying to get to run. Furthermore I have altered the httpd.conf file to add AddHandler cgi-script .cgi .pl .asp .py and Options Indexes FollowSymLinks Includes ExecCGI. The simple code that I am trying to get to run is

#!"C:\Python34\python.exe"  

print "Content-Type: text/html\n\n";  

print  

print "OK";  

Any help would be greatly appreciated. Remember that a perl script like the one below, works perfectly fine.

#!"C:\xampp\perl\bin\perl.exe"  

print "Content-Type: text/html\n\n";  

print "OK";  

Thank you so much for any help that you can give. It is greatly appreciated. Also I am using Windows and Xampp

Upvotes: 0

Views: 6755

Answers (1)

mhawke
mhawke

Reputation: 87074

You seem to be using Python 3.4 in which print is a function and not a statement. Try changing your print statements to print() function calls.

Upvotes: 1

Related Questions