按照《python3网络爬虫开发实践》这本书上的方法(用pip)安装好了tornado,然后把书上的helloworld程序敲到python里头运行出现错误,代码和错误如下图所示:
tornado版本为6.0.4,python版本为3.8.3
大佬求教
放弃,学其他的web框架,建议直接学django
问题解决了吗?
我也遇到了这个问题
解决了:
是由于 python3.8 asyncio 在 windows 上默认使用 ProactorEventLoop 造成的,而不是之前的 SelectorEventLoop。jupyter 依赖 tornado,而 tornado 在 window 上需要使用 SelectorEventLoop,所以产生这个报错.
请看官方文档:https://www.tornadoweb.org/en/stable/index.html#installation
解决方法是,在 tornado开始执行前添加以下代码,在windows下单独处理:
import platform
if platform.system() == "Windows":
import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
参见Python3.8 tornado报错NotImplementedError(转载)_Hank's Techblog-CSDN博客_python tornado notimplementederror https://blog.csdn.net/hank5658/article/details/106870245?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1