CGIHTTPRequestHandler giving an error

745 views Asked by At

CGIHTTPRequestHandler gives an import error saying no such module available.

import CGIHTTPServer

import BaseHTTPServer

class Handler(CGIHTTPServer.CGIHTTPRequestHandler):

    cgi_directories = ["/cgi"]

PORT = 8000

httpd = BaseHTTPServer.HTTPServer(("", PORT), Handler)

print "serving at port", PORT

httpd.serve_forever()

I get the following response.

Traceback (most recent call last):
  File "D:/PYTHON/cgiserver.py", line 1, in <module>
    from CGIHTTPServer import CGIHTTPRequestHandler
  File "D:/PYTHON\CGIHTTPServer.py", line 9, in <module>
    handler = CGIHTTPServer.CGIHTTPRequestHandler
AttributeError: 'module' object has no attribute 'CGIHTTPRequestHandler'
1

There are 1 answers

0
falsetru On BEST ANSWER

Rename CGIHTTPServer.py. (And don't forget to remove CGIHTTPServer.pyc.)

Otherwise it conflicts with the standard module CGIHTTPServer; prevents you to import the module.