开发者

Hello world failing

开发者 https://www.devze.com 2023-03-22 08:28 出处:网络
I\'ve just installed python 3.2.1 (32-bit) and cherrypy 3.2.1 (CherryPy-3.2.1.win32-py3.exe) on my Windows 7 box and have tried the hello world example (executed via PyScripter) but it hangs after the

I've just installed python 3.2.1 (32-bit) and cherrypy 3.2.1 (CherryPy-3.2.1.win32-py3.exe) on my Windows 7 box and have tried the hello world example (executed via PyScripter) but it hangs after the Engine bus STARTED message.

If I try to start it via the python.exe, I get the following log:

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\threa开发者_如何学JAVAding.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

What am I missing?

Code:

import cherrypy

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

cherrypy.quickstart(HelloWorld())

EDIT: Bonus-info: I've tried various things to remedy the situation with no result. Installing the 64-bit version of python didn't help as cherrypy doesn't support 64-bit (unless, I'm mistaken). I've tried re-installing both python and the cherrypy packages, and I've tried deactivating all other things that might block it (IIS). All to no avail :-(

EDIT2: Second bonus - everything works if I install it with python 2.7.2, so seems it is only a problem with 3.x (I've tried 3.0.1 as well - same problem)


I have encountered two errors:

1 - open your browser before starting the script, so you'll not have any problem.

2 - if you use a personal firewall or an antivirus that handles HTTP protection, be sure he is not protecting the 8080 port, for example ESET Antivirus will not let you use the 8080 and CherryPy will say that the port is not free.

0

精彩评论

暂无评论...
验证码 换一张
取 消