Java教程

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 -i https://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" ,命令见上面。

 

这篇关于Jupyter Notebook实现代码的自动补全的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!