在jupyter notebook实现代码自动提示

发布时间 2023-09-23 11:19:56作者: 照眠

为什么代码自动提示很重要?

在使用Jupyter Notebook编写代码时,代码自动提示是一项非常有用的功能。它可以帮助你快速找到函数、方法和变量的名称,提高了代码的编写效率,同时减少了潜在的拼写和语法错误。效果如下:

image-20230923105138962

本篇博客将介绍如何在Jupyter Notebook中启用和使用代码自动提示功能。

启用代码自动提示

1.安装Jupyter Notebook:如果你还没有安装Jupyter Notebook,首先需要安装它。你可以使用pip来安装,并且确认安装的版本无误解。

pip install jupyter notebook==6.4.8 -i https://pypi.tuna.tsinghua.edu.cn/simple

2.安装并激活Jupyter的代码自动提示插件:为了启用代码自动提示,你需要安装适当的插件。一个常用的插件是jupyter_contrib_nbextensions,它包含了很多有用的扩展功能,包括代码自动提示。你可以使用以下命令来安装:

pip install jupyter_contrib_nbextensions 
jupyter contrib nbextension install --user

3.安装并激活指定版本的jupyter的服务器扩展

pip install jupyter_nbextensions_configurator==0.5.0 https://pypi.tuna.tsinghua.edu.cn/simple
jupyter nbextensions_configurator enable --user

4.打开jupyter notebook

jupyter notebook

5.启动Hinterland

image-20230923104704097

6.验证自动补全成功

image-20230923105054253