Python3.8安裝 jupyter報錯 NotImplementedError

報錯如下:

 

原因:

是由於 python3.8 asyncio 在 windows 上默認使用 ProactorEventLoop 造成的,而不是之前的 SelectorEventLoop。jupyter 依賴 tornado,而 tornado 在 window 上需要使用 SelectorEventLoop,所以產生這個報錯。

On Windows, Tornado requires the ``WindowsSelectorEventLoop``. This is
the default in Python 3.7 and older, but Python 3.8 defaults to an
event loop that is not compatible with Tornado. Applications that use
Tornado on Windows with Python 3.8 must call
``asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())``
at the beginning of their ``main`` file/function.
 

而對於像 jupyter 這種依賴於 tornado 的庫,則無法用這種方式。目前這個問題已由 python 官方跟蹤:https://bugs.python.org/issue37373

臨時解決辦法:

修改 python安裝目錄\Lib\site-packages\tornado\platform\asyncio.py

import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

也就是在 import asyncio 之後,手動讓 tornado 選擇 SelectorEventLoop,這樣 jupyter 就可以正常使用了。

所以現在其實不太建議升級到 python3.8

Python目前最新版本是3.8.0,2019年10月14日發佈的,從學習者與開發者角度,都不應該選擇最新版本,建議選擇第一版是至少一年前發佈的,這樣很多第三方庫也跟進變化了。

2019年12月10日,推薦選擇:

3.7.x版本,因爲3.7.0版本是2018年6月發佈的

 

發佈了453 篇原創文章 · 獲贊 192 · 訪問量 183萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章