使用龙卷风网络服务器运行 hello world 时出现问题(Python 2.5,Win 7)
我在 Windows 7(64 位)上使用 Python 2.5。
我安装了 pycurl-7.15.5.1(带有 win 二进制文件)和tornado(使用 pip)。
当我运行以下 hello world 代码时:
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'
I am using Python 2.5 on Windows 7 (64bit).
I installed pycurl-7.15.5.1 (with win binaries) and tornado (using pip).
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()
I get the following error:-
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'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
显然,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:
or maybe
来自tornado 网页 (http://www.tornadoweb.org/)
平台:Tornado 应该在任何类 Unix 平台上运行,尽管为了获得最佳性能和可扩展性,建议仅使用 Linux 和 BSD(包括 Mac OS X 等 BSD 衍生产品) 。
我认为它与windows不兼容
与tornado类似的事情可以通过twisted框架来实现 http://twistedmatrix.com 它可以工作在 Windows 下,
有趣的指针是
http://twistedmatrix.com/documents/current/web/howto/web-in-60/index.html
和
http://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-content.html
from tornado web page (http://www.tornadoweb.org/)
Platforms: Tornado should run on any Unix-like platform, although for the best performance and scalability only Linux and BSD (including BSD derivatives like Mac OS X) are recommended.
I think it is not compatible with windows
Things similar with tornado can be achieve with twisted framework http://twistedmatrix.com which works under windows
interesting pointers are
http://twistedmatrix.com/documents/current/web/howto/web-in-60/index.html
and
http://twistedmatrix.com/documents/current/web/howto/web-in-60/dynamic-content.html