jupyter notebook7.3.3版本无法进行代码补全

该文章已生成可运行项目,

一、按tab键补全

jupyter notebook使用默认的自动补全是关掉的。要打开自动补全,需修改默认配置。

命令行中输入:ipython profile create

以上命令会在~/.ipython/profile_default/目录下生成ipython_config.py和ipython_kernel_config.py

需要修改(ipython_config.py)的以下几行,将开启补全功能:

## Activate greedy completion PENDING DEPRECTION. this is now mostly taken care
#  of with Jedi.
#
#  This will enable completion on elements of lists, results of function calls,
#  etc., but can be unsafe because the code is actually evaluated on TAB.
c.Completer.greedy = True
## Experimental: restrict time (in milliseconds) during which Jedi can compute
#  types. Set to 0 to stop computing types. Non-zero value lower than 100ms may
#  hurt performance by preventing jedi to build its cache.
c.Completer.jedi_compute_type_timeout = 400
## Experimental: Use Jedi to generate autocompletions. Off by default.
c.Completer.use_jedi = True

重启jupyter后生效。

以上操作后,在编写代码是发现不是自动不全,是要按下tab键就可以补全了

二、自动补全

如果想自动代码补全。Jupyter Notebook 7.0以上版本移除了移除了 notebook.nbextensions 模块,所以通过如下方式安装nbextension,会报错:ModuleNotFoundError: No module named 'notebook.extensions'

  • pip install jupyter_contrib_nbextensions

  • jupyter contrib nbextension install --user

需通过界面设置,操作流程如下:

1、打开设置界面

2、打开autocompletion开关

3、验证效果

本文章已经生成可运行项目
(base) PS C:\Users\HL> conda install -c conda-forge ipywidgets jupyter_contrib_nbextensions Channels: - conda-forge - defaults Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: C:\Users\HL\miniconda3 added / updated specs: - ipywidgets - jupyter_contrib_nbextensions The following NEW packages will be INSTALLED: importlib_resourc~ conda-forge/noarch::importlib_resources-6.5.2-pyhd8ed1ab_0 ipython_genutils conda-forge/noarch::ipython_genutils-0.2.0-pyhd8ed1ab_2 ipywidgets conda-forge/noarch::ipywidgets-8.1.5-pyhd8ed1ab_1 jupyter_contrib_c~ conda-forge/noarch::jupyter_contrib_core-0.4.0-pyhd8ed1ab_1 jupyter_contrib_n~ conda-forge/noarch::jupyter_contrib_nbextensions-0.7.0-pyhd8ed1ab_0 jupyter_highlight~ conda-forge/win-64::jupyter_highlight_selected_word-0.2.0-py310h5588dad_1005 jupyter_latex_envs conda-forge/noarch::jupyter_latex_envs-1.4.6-pyhd8ed1ab_1002 jupyter_nbextensi~ conda-forge/noarch::jupyter_nbextensions_configurator-0.6.1-pyhd8ed1ab_0 jupyterlab_widgets conda-forge/noarch::jupyterlab_widgets-3.0.13-pyhd8ed1ab_1 libxslt conda-forge/win-64::libxslt-1.1.37-h0192164_0 lxml conda-forge/win-64::lxml-4.9.1-py310he2412df_0 nbconvert pkgs/main/win-64::nbconvert-7.16.6-py310haa95532_0 nbconvert-pandoc pkgs/main/win-64::nbconvert-pandoc-7.16.6-py310haa95532_0 notebook conda-forge/noarch::notebook-7.3.3-pyhd8ed1ab_0 pandoc conda-forge/win-64::pandoc-3.6.4-h57928b3_0 widgetsnbextension conda-forge/noarch::widgetsnbextension-4.0.13-pyhd8ed1ab_1 Proceed ([y]/n)? y Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: - Traceback (most recent call last): File "C:\Users\HL\miniconda3\lib\site-packages\jupyter_contrib_core\notebook_compat\nbextensions.py", line 6, in > from notebook.extensions import B
04-01
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值