1. 程式人生 > 其它 >Jupyter Notebook實現程式碼的自動補全

Jupyter Notebook實現程式碼的自動補全

Jupyter Notebook實現程式碼的自動補全的功能,需要按照以下擴充套件庫:jupyter_contrib_nbextensions和jupyter_nbextensions_configurator

安裝方式:pip install jupyter_XX_XX -i https://XXXXX.XXX.XXX

個人本地之前是安裝了Python、Pip、Jupyter等環境,所以此次按照只需要裝外掛庫。

總結為四部曲就是:

1、pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple

2、jupyter contrib nbextension install

3、pip install jupyter_nbextensions_configurator -i https://pypi.mirrors.ustc.edu.cn/simple

4、jupyter nbextensions_configurator enable

這是原來的樣子:

下面開始我們的安裝!

第一步:安裝pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple

第二步:安裝另個外掛,pip install jupyter_nbextensions_configurator -ihttps://pypi.mirrors.ustc.edu.cn/simple

此時,完成安裝後,重啟jupyter Notebook,發現報這個錯誤“Config option template_path*not recognized byLenvsTocHTMLExporter”,如下截圖:

於是查詢原因是因為,

  • 原因是nbconvert6.0.0版本以上的某些引數的名稱發生了更改,與原先版本不相容,需要將版本降低到5.6.1

  • 如果使用如下命令,則會報錯找不到這個模組,我靈機一動,直接去官網找下載

於是重新指定版本安裝了nbconvert,命令如下:conda install "nbconvert=5.6.1" -i https://pypi.mirrors.ustc.edu.cn/simple

提示安裝成功,重啟Jupyter Notebook,發現依然沒有,發現自己第二步安裝完成,沒有設定 該外掛為 enable狀態。執行該命令:jupyter nbextensions_configurator enable --user

重啟Jupyter Notebook,則會出現

但是發現裡面沒有內容,發現自己又少做了一步,於是:jupyter contrib nbextension install

此時再重啟,jupyter Notebook,外掛庫中內容都顯示了,如下圖:

最後我們檢視下,是否能夠自動補全程式碼,哇,確實OK了。

最後做個總結,四部曲。不然就會像我一樣,每次出現問題又去找原因。

所謂的四部曲就是:

1、pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple

2、jupyter contrib nbextension install

3、pip install jupyter_nbextensions_configurator -i https://pypi.mirrors.ustc.edu.cn/simple

4、jupyter nbextensions_configurator enable

如果出現我以上的配置路徑問題,則回退conda install "nbconvert=5.6.1" ,命令見上面。