前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >机器学习笔记之jupyter自动代码补全

机器学习笔记之jupyter自动代码补全

作者头像
Jetpropelledsnake21
发布2021-01-14 10:33:23
8400
发布2021-01-14 10:33:23
举报
文章被收录于专栏:JetpropelledSnakeJetpropelledSnake

0x00 概述

jupyter默认代码自动补全是关闭的,要打开自动补全,需修改默认配置。

0x01 通过修改jupyter配置文件打开代码自动补全(不推荐)

在WIndows开始菜单中找到Anaconda,打开了Anaconda Prompt,

命令行中输入:

代码语言:javascript
复制
ipython profile create

以上命令会在C:\User\$你的用户名\.ipython\profile_default\目录下生成ipython_config.py和ipython_kernel_config.py

代码语言:javascript
复制
## 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后生效。

代码语言:javascript
复制
# 以上操作后,在编写代码是发现不是自动不全,是要按下tab键才可以补全,每次还要手动tab一下。比较麻烦

0x02 通过安装nbextensions实现代码自动补全(推荐)

2.1 更换Anaconda3 pip安装数据源

打开Anaconda Prompt,使用命令 pip install jupyter_contrib_nbextensions ,默认是从官方源下载数据,比较慢而且容易中断报错;

执行如下命令将pip安装源切换到国内阿里云

代码语言:javascript
复制
pip install web.py -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

以下pip源可供选择:

代码语言:javascript
复制
#阿里云 http://mirrors.aliyun.com/pypi/simple/

#中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 

#豆瓣(douban) http://pypi.douban.com/simple/ 

#清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/

#中国科学技术大学http://pypi.mirrors.ustc.edu.cn/simple/

2.2 安装nbextensions

代码语言:javascript
复制
# pip install jupyter_contrib_nbextensions

# jupyter contrib nbextension install --user

2.3 安装 nbextensions_configurator

代码语言:javascript
复制
# pip install jupyter_nbextensions_configurator

# jupyter nbextensions_configurator enable --user

2.4 在Jupyter设置nbextensions

按照如下配置

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2021-01-12 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 0x00 概述
  • 0x01 通过修改jupyter配置文件打开代码自动补全(不推荐)
  • 0x02 通过安装nbextensions实现代码自动补全(推荐)
    • 2.1 更换Anaconda3 pip安装数据源
      • 2.2 安装nbextensions
        • 2.3 安装 nbextensions_configurator
          • 2.4 在Jupyter设置nbextensions
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档