你好世界失败了

时间:2011-07-24 14:36:13

标签: python-3.x cherrypy

我刚刚在我的Windows 7机器上安装了python 3.2.1(32位)和cherrypy 3.2.1(CherryPy-3.2.1.win32-py3.exe),并尝试了hello world示例(通过执行PyScripter)但它在引擎总线启动消息后挂起。

如果我尝试通过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 - 同样的问题)

1 个答案:

答案 0 :(得分:2)

我遇到了两个错误:

1 - 在启动脚本之前打开浏览器,这样你就不会有任何问题。

2 - 如果您使用个人防火墙或处理HTTP保护的防病毒软件,请确保他不保护8080端口,例如ESET Antivirus不会让您使用8080而CherryPy会说该端口不是免费的