使用Jupyter
安装本体和nbextensions
安装python3.7+
pip install jupyter
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
好用的扩展推荐
Code prettify、Hinterland、Table of Contents (2)、Scratchpad、Collapsible Headings、A 2to3 converter
插入代码控制的插件
Jupyter-notify 网页通知提示插件
pip install jupyternotify
%load_ext jupyternotify # 载入插件
%autonotify -a 30
对所有执行超过30s的cells在运行结束后进行通知,只关注特定的cell,那么可以将%autonotify -a 30
去掉,然后在对应的格子中加入%%notify
,在Jupyter运行的时候自动加载该插件,在需要向Notebook的config文件中加入下列代码
c.InteractiveShellApp.extensions = [
'jupyternotify'
]
显示python循环进度
pip install tpdm
from tqdm import tnrange, tqdm_notebook
from time import sleep
## 原来的循环
for i in range(10):
for j in tqdm_notebook(range(100), desc='2nd loop'):
sleep(0.01)
## 使用tqdm显示进度的循环
for i in tnrange(10, desc='1st loop'):
for j in tqdm_notebook(range(100), desc='2nd loop'):
sleep(0.01)
修改默认文件夹路径
- cmd输入
jupyter notebook --generate-config
,在家目录下生成配置文件
- 查找关键词“c.NotebookApp.notebook_dir”,把该行行首的井号(#)删除
- 在该行写入新路径
修改默认浏览器
打开配置文件,找到c.NotebookApp.browser
import webbrowser
webbrowser.register('chrome', None, webbrowser.GenericBrowser(u'C:\\Program Files\\chrome.exe'))
c.NotebookApp.browser = 'chrome'
设置登录密码
- 打开配置文件,找到
c.NotebookApp.allow_password_change
- 设置为
False
,并删掉#
- cmd运行
jupyter notebook password
,设置密码