最近有需求,要把几个库更新到最新版本。于是,耍个机灵,就用了pip review批量把所有库更新到最新版本了,然后再打开jupyter notebook就无法运行了,心累,倒腾了几个小时。最后是在Bing上找到的解决办法。
原因是在于 tornado 这个库,你可以用pip list看一下是否有这个库,而且最最最重要的是看一下它的版本,如果是6.0及以上,恭喜你,问题已经找到了。
解决方法:
#建议手打,复制网页的代码到命令行,可能会出现莫名其妙的字符错误
pip install tornado==5.1.1
只要是小于6.0版本都能解决此问题,具体的原因我大概看了一下 tornado 的介绍,好像是6.0以后不支持py3了,不太清楚,总之成功解决了。
2021-9-18@更新
因为好多人都看到这里了,我觉得自己还是应该去查一下。在Tornado 官方文档中看到了6.0的release note。
What’s new in Tornado 6.0
Mar 1, 2019
Backwards-incompatible changes
- Python 2.7 and 3.4 are no longer supported; the minimum supported Python version is 3.5.2.
- APIs deprecated in Tornado 5.1 have been removed. This includes the
tornado.stack_context
module and mostcallback
arguments throughout the package. All removed APIs emitted DeprecationWarning when used in Tornado 5.1, so running your application with the-Wd
Python command-line flag or the environment variablePYTHONWARNINGS=d
should tell you whether your application is ready to move to Tornado 6.0..WebSocketHandler.get
is now a coroutine and must be called accordingly in any subclasses that override this method (but note that overridingget
is not recommended; eitherprepare
oropen
should be used instead).
英文也很简单,意思就是Tornado 6.0不再支持py3.4及以下版本了,但是我估计好多人都是用不到这个库的,如果用到了Tornado,你大概率也不会找到这篇文章。
- 所以两种方法,第一种最简单,直接降Tornado版本 < 6.0就好了
- 还有一种就是升级你的py版本,至少是3.5.2,但升级py版本,其他库有没有支持也不好说,所以如果你必须要使用Tornado 6.0及以上版本,那么升级py版本的时候,最好先查看其他重要库是否支持。
2021-5-1 遇到一个内核一直启动失败的问题
最后查到了应该是公司防火墙设置的问题,导致内核一直连接失败。最后在stackoverflow这个回答中找到了解决办法:
jupyter notebook --no-browser --ip=0.0.0.0 --port=8888