Python CGI script won't execute if I 'import cgi'

160 Views Asked by At
#!/usr/bin/python   
import sys, os, cgi
print "Content-type:text/html;charset=utf-8    \r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program %s</h2>'
print '</body>'
print '</html>'

This executes to show a prompt Error 500 that says 'End of script output before headers: connect.py', which clearly means it stops executing the script immediately after the import fails.

The same code executes and displays Hello World if I import only sys and os, without cgi.

I checked the path from the CGI script, and it does include /usr/lib/python2.7

Further, on checking the Apache error logs, I see this error message:

[Tue Jun 09 17:49:39.552088 2015] [cgi:error] [pid 18552] [client 106.51.234.247:17541] AH01215: python: relocation error: python: symbol SSL_load_error_strings, version OPENSSL_1.0.0 not defined in file libssl.so.1.0.0 with link time reference
[Tue Jun 09 17:49:39.552292 2015] [cgi:error] [pid 18552] [client 106.51.234.247:17541] End of script output before headers: connect.py
0

There are 0 best solutions below