下载最新版本Python并安装
https://www.python.org/downloads/ 安装时一定要勾选“加入路径到环境变量”的选项。
更新PIP
python -m pip install --upgrade pip
安装Jupyter(使用清华源满速下载安装)
pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple
启动Jupyter Notebook的批处理文件
可以写一个BAT脚本,保存为 Jupyter.bat
rem -- start_jupyter_notebook.bat ---
jupyter notebook
pause
设置默认目录
直接打开的jupyter notebook界面,显示的目录位置是jupyter的默认目录。如何修改成我们自己的工作目录?jupyter所有的配置都放在了配置文件jupyter_notebook_config.py中,找到并修改该文件即可。
3.1 修改配置文件jupyter_notebook_config.py:在cmd中输入 jupyter notebook --generate-config 提示 Writing default config to: C:\Users\uusseerr\.jupyter\jupyter_notebook_config.py 修改jupyter_notebook_config.py , 前面的# 要删除。
c.NotebookApp.notebook_dir = 'D:\\PythonProg'
设置字体
修改C:\Python38\Lib\site-packages\notebook\static\custom\custom.css 这个文件:
.CodeMirror pre {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
* {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei";}
div.output_area pre {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.input_prompt {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.out_prompt_overlay {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
div.prompt {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei"; font-size: 10pt;}
span.cm-comment {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei" !important; font-style:normal !important; color:#FFAE3C !important;}
code {font-family: JetBrains Mono, "Microsoft YaHei Mono", "Microsoft YaHei";}
.rendered_html code {
border: 0;
padding: 2px 4px;
color:#c7254e;
background-color: #f2f2f2;
font-size: 100%;
}
.container { width:98% !important; }
自动补全
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user --skip-running-check
在Jupyter Notebook中使用控件
pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension
看到如下信息:
Enabling notebook extension jupyter-js-widgets/extension...
- Validating: ok
示例代码:
import ipywidgets as wg
from IPython.display import display
@wg.interact_manual()
def doing_actions(name='',company=''):
df=print(name,' works in ',company)
return df
|