Python jupyter代码自动补全

Python jupyter代码自动补全

1 Jupyter Notebook主题字体设置及自动代码补全

1.1 安装#

    Jupyter Notebook 用久了就离不开了,然而自带的主题真的不忍直视。为了视力着想,为了自己看起来舒服,于是折腾了一番。。在 github 上发现了一个 [jupyter-themes](https://github.com/dunovank/jupyter-themes) 工具,可以通过 pip 安装,非常方便使用。<br />首先是主题下载,为了速度快点,使用豆瓣源,命令行如下所示:
pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com --no-dependencies jupyterthemes==0.18.2

安装好了,有的电脑可能会提示缺少 lesscpy,继续 pip 安装

pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com lesscpy

然后是对主题选择、字体大小进行设置,我总结了一个我最喜欢的

jt --lineh 140 -f consolamono -tf ptmono -t grade3 -ofs 14 -nfs 14 -tfs 14 -fs 14 -T -N

命令行的格式的解释如下表所示:

cl optionsargdefault
Usage help-h
List Themes-l
Theme Name to Install-t
Code Font-f
Code Font-Size-fs11
Notebook Font-nf
Notebook Font Size-nfs13
Text/MD Cell Font-tf
Text/MD Cell Fontsize-tfs13
Pandas DF Fontsize-dfs9
Output Area Fontsize-ofs8.5
Mathjax Fontsize (%)-mathfs100
Intro Page Margins-mauto
Cell Width-cellw980
Line Height-lineh170
Cursor Width-cursw2
Cursor Color-cursc
Alt Prompt Layout-altp
Alt Markdown BG Color-altmd
Alt Output BG Color-altout
Style Vim NBExt*-vim
Toolbar Visible-T
Name & Logo Visible-N
Kernel Logo Visible-kl
Reset Default Theme-r
Force Default Fonts-dfonts

附上最终效果:


1.2 实现自动代码补全

首先安装 nbextensions

pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com jupyter_contrib_nbextensions
jupyter contrib nbextension install --user

然后安装 nbextensions_configurator

pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com  jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user


如果提示缺少依赖,就安装对应依赖即可。
最后重启 jupyter,在弹出的主页面里,能看到增加了一个 Nbextensions 标签页,在这个页面里,勾选 Hinterland 即启用了代码自动补全,如图所示:


2 更新#

   其实大多都是缺少依赖,我在今天(2020/04/08)重新安装,按照上面的步骤,也没有 `Nbextensions` ,并且没有报错,后来卸载重装,提示我缺少 `msgpack` ,把它安装后,重新配置,`Nbextensions` 又出来了
  • 如果已经安装了,先卸载:
pip uninstall jupyter_contrib_nbextensions
pip uninstall jupyter_nbextensions_configurator

  • 打开 Anaconda Prompt 窗口,执行以下命令:
pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip install -i http://pypi.douban.com/simple --trusted-host pypi.douban.com  jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
  • 最后重新启动 Jupyter Notebook 后,就发现 Nbextensions 标签又有了


  • 5
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值