anaconda jupyternotebook 补全

jupyter notebook代码自动补全

一直用anaconda自带的spyder写代码,今天突然想试试jupyternotebook,写了一会总觉得没有代码补全不太方便,就百度查,然后总结了以下步骤如下:
1、命令行执行安装nbextensions

pip install jupyter_contrib_nbextensions -i https://pypi.mirrors.ustc.edu.cn/simple
jupyter contrib nbextension install --user

2、安装nbextensions_configurator

pip install --user jupyter_nbextensions_configurator 
jupyter nbextensions_configurator enable --user

这两部完成后,基本就可以了,网上说有可能会有报错,缺少依赖环境,这个我倒没遇到,如果真缺少了,那就根据提示pip或者conda install就好了
anaconda jupyternotebook 补全_第1张图片

另外插一嘴:在命令行窗口运行jupyter notebook时候,命令行窗口所在的文件夹是哪个位置,运行后的根目录就是那个位置:如下:我是直接win+r–>cmd–>jjupyter notebook,在默认位置运行的,就出现这样的:

anaconda jupyternotebook 补全_第2张图片
anaconda jupyternotebook 补全_第3张图片
anaconda jupyternotebook 补全_第4张图片
3、上面的安装完成后,记得重启jupyter,就可以看到那个Nbextensions标签了,点击它,出现下面的界面,勾选Hinterland
anaconda jupyternotebook 补全_第5张图片
4、结果:连from都可以提示,结果棒棒哒
anaconda jupyternotebook 补全_第6张图片

PS:上面的是安装了插件,又看到一个方法,据说可以直接修改配置文件就行,我没测试,先收藏:

ipython profile create

执行上述命令后会在.ipython/profile_default/目录下生成ipython_config.py和ipython_kernel_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即可

你可能感兴趣的:(python-学习总结,python,jupyter,notebook)