本文介绍了龙卷风Web服务器运行Hello World时出现问题(Python 2.5,Win 7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在Windows 7(64位)上使用Python 2.5.
I am using Python 2.5 on Windows 7 (64bit).
我安装了pycurl-7.15.5.1(带有Win Binaries)和龙卷风(使用pip).
I installed pycurl-7.15.5.1 (with win binaries) and tornado (using pip).
当我运行以下hello world代码时:
When I run the following hello world code:
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello World!")
if __name__=='__main__':
app = tornado.web.Application([(r"/",MainHandler),])
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
我收到以下错误:-
Traceback (most recent call last):
File "hello_tornado.py", line 11, in <module>
application.listen(8888)
File "c:\Python25\Lib\site-packages\tornado\web.py", line 1193, in listen
server.listen(port, address)
File "c:\Python25\Lib\site-packages\tornado\netutil.py", line 100, in listen
sockets = bind_sockets(port, address=address)
File "c:\Python25\Lib\site-packages\tornado\netutil.py", line 263, in bind_sockets
sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
AttributeError: 'module' object has no attribute 'IPV6_V6ONLY'
推荐答案
Tornado显然在Windows上有一些IPv6混淆.您可以通过指定要侦听的IP来修复它,如下所示:
Tornado has some IPv6 confusion on windows apparently. You can fix it by specifiyig the IP you want it to listen on like this:
application.listen(8888,'127.0.0.1')
或者也许
application.listen(8888,'0.0.0.0')
这篇关于龙卷风Web服务器运行Hello World时出现问题(Python 2.5,Win 7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!