2011-07-24 240 views
3

我刚刚在我的Windows 7盒子上安装了python 3.2.1(32位)和cherrypy 3.2.1(CherryPy-3.2.1.win32-py3.exe)并尝试了hello world example (通过PyScripter执行),但在引擎总线STARTED消息后挂起。你好世界失败

如果我试图通过python.exe启动它,我得到以下日志:

C:\Program Files (x86)\Python32>python hello.py 
[24/Jul/2011:16:24:03] ENGINE Listening for SIGTERM. 
[24/Jul/2011:16:24:03] ENGINE Bus STARTING 
CherryPy Checker: 
The Application mounted at '' has an empty config. 

[24/Jul/2011:16:24:03] ENGINE Started monitor thread 'Autoreloader'. 
[24/Jul/2011:16:24:03] ENGINE Started monitor thread '_TimeoutMonitor'. 
[24/Jul/2011:16:24:03] ENGINE Serving on 127.0.0.1:8080 
[24/Jul/2011:16:24:03] ENGINE Bus STARTED 
Exception in thread CP Server Thread-4: 
Traceback (most recent call last): 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 693, in read_request_headers 
    read_headers(self.rfile, self.inheaders) 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 202, in read_headers 
    raise ValueError("Illegal end of headers.") 
ValueError: Illegal end of headers. 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 1024, in communicate 
    req.parse_request() 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 578, in parse_request 
    success = self.read_request_headers() 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 696, in read_request_headers 
    self.simple_response("400 Bad Request", ex.args[0]) 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 840, in simple_response 
    status = str(status) 
TypeError: 'tuple' object is not callable 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "C:\Program Files (x86)\Python32\lib\threading.py", line 736, in _bootstr 
ap_inner 
    self.run() 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 1174, in run 
    conn.communicate() 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 1080, in communicate 
    req.simple_response("500 Internal Server Error", format_exc()) 
    File "C:\Program Files (x86)\Python32\lib\site-packages\cherrypy\wsgiserver\ws 
giserver3.py", line 840, in simple_response 
    status = str(status) 
TypeError: 'tuple' object is not callable 

我缺少什么?

代码:

import cherrypy 

class HelloWorld: 
    def index(self): 
     return "Hello world" 
    index.exposed = True 

cherrypy.quickstart(HelloWorld()) 

编辑:奖金-的信息:我已经试过各种事情来弥补没有结果的情况。安装64位版本的python并没有帮助,因为cherrypy不支持64位(除非我错了)。我已经尝试重新安装python和cherrypy软件包,并尝试禁用所有其他可能会阻止它的东西(IIS)。一切都无济于事:-(

EDIT2:二奖金 - 如果我使用Python 2.7.2安装一切正常,如此看来,这是只有3.X(我试过3.0.1,以及一个问题 - 同样的问题)

回答

2

我遇到了两个错误:

1 - 启动脚本之前打开浏览器,所以你不会有任何问题

2 - 如果你使用个人防火墙或。防病毒,处理HTTP保护,确保他没有保护8080端口,例如ESET Antivirus不会让你使用8080,而CherryPy会说这个端口不是免费的。

+0

因为它在python 2.7.2中工作 - 两个sugggestion都不成立。 – Goblin

+0

在python 3中,它们分开二进制和文本,所以这就是为什么WSGI和python 3有问题,所以我认为这是问题 http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface#WSGI_and_Python_3 不知道如果这个问题已经解决,因为我开始只是在python 3和互联网.... – Abdelouahab

+0

啊,谢谢!这听起来是合理的 - 我刚刚开始使用python3和web :-)希望他们得到解决,因为cherrypy是目前运行python3.x的唯一web模块... – Goblin