2014-01-17 64 views
1

CGIHTTPRequestHandler给出一个导入错误,说没有这样的模块可用。CGIHTTPRequestHandler给出错误

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() 

我收到以下回复。

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' 

回答

2

重命名CGIHTTPServer.py。 (并且不要忘记删除CGIHTTPServer.pyc。)

否则它与标准模块CGIHTTPServer冲突;阻止您导入模块。

+0

嘿谢谢..这解决了这个问题。 –

+0

大声笑,这样一个简单的问题蟒蛇noob问题的答案。 – vinhboy