title: Error with executing Python files in cgi-bin (have tried enabling CGI Scripts in Apache)
body: <p>I have a running Apache2 server on Ubuntu, with PHP installed.
  My root folder is <code>/usr/local/apache2/htdocs</code>.</p>
  
  <p>I have put a test python script in <code>/usr/local/apache2/cgi-bin</code>, named <code>test.py</code>.</p>
  
  <p><strong>test.py</strong></p>
  
  <pre><code>#!/usr/bin/python
  import cgi
  import cgitb; cgitb.enable()
  print "Content-Type: text/plain\r\n\r\n"
  print 'hi'
  </code></pre>
  
  <p>I access this in the browser via <code>http://localhost/cgi-bin/test.py</code>.  At the moment, it just displays the Python code that I just typed out, rather than executing it.  I have looked extensively at online documentations and other stackoverflow questions that address this issue.  </p>
  
  <p>From that research I changed my <code>httpd.conf</code> file to include a few <code>Directory</code>'s.</p>
  
  <p><strong>httpd.conf</strong> (stuff added to end of it)</p>
  
  <pre><code>ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/"
  
  &lt;Directory "/usr/local/apache2/cgi-bin"&gt;
      Options ExecCGI
      SetHandler cgi-script
  &lt;/Directory&gt;
  
  &lt;Directory "/usr/local/apache2"&gt;
      AddHandler cgi-script .py
      AllowOverride None
      Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
      Order allow,deny
      Allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>I have restarted/hard-started/stopped Apache and was able to run the Python file successfully through the command-line, but still no luck with actually executing the python file through the browser.  I have even checked the Apache error log, but saw no indication of the problem. Can anyone offer some advice?</p>
  
  <p>Thank you</p>