ㅤcoderitl
V1
2022/02/07阅读:68主题:萌绿
Jupyter-NoteBook
Jupyter NoteBook 运行配置
什么是 Jupyter NoteBook
Jupyter Notebook, 以前又称为IPython notebook,是一个交互式笔记本, 支持运行40+种编程语言. 可以用来编写漂亮的交互式文档.
检测 Python 系统版本并升级
# 检测 python 版本信息
python --version
Eg: Python 3.9.5
# 升级
python -m pip install --upgrade pip
更换pip
镜像
# 创建 pip 文件夹
C:\Users\[coderitl 用户名]\pip[自行新建 pip 文件夹]
#创建文件
pip.ini
# 文件内容
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/ # 更换可选择下列地址
[install]
trusted-host = mirrors.aliyun.com # 更换可选择下列地址
# 其他镜像源
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
清华: https://pypi.tuna.tsinghua.edu.cn/simple
阿里云: https://mirrors.aliyun.com/pypi/simple/
华中理工大学: https://pypi.hustunique.com/
山东理工大学: https://pypi.sdutlinux.org/
安装、运行、配置: Jupyter NoteBook
-
安装
pip install jupyter
-
运行
jupyter notebook
-
运行方式
运行jupyter -
配置
Jupyter NoteBook
打开默认目录
# 获取配置文件目录
进入 Windows(cmd->dos)命令行界面,输入: jupyter notebook --generate-config 命令后会返回配置文件路径
# 使用相应记事本打开,修改如下,之后保存关闭
在文件中搜索 notebook_dir
-
修改为如下信息
修改jupyter默认打开路径 -
创建一个文件
在jupyter中创建python文件 -
运行
运行python文件,快捷键ctrl+Enter
主题配置
-
安装主题
# 安装主题
pip install jupyterthemes
-
显示主题列表
➜ ~ jt -l
Available Themes:
chesterish
grade3
gruvboxd
gruvboxl
monokai
oceans16
onedork
solarizedd # 墨绿
solarizedl # 淡黄
➜ ~ ✗
-
设置 主题
,字体
,字体大小
,宽度
…
# 设置
jt -t onedork -f fira -fs 12 -cellw 96% -ofs 12 -dfs 12 -T
# 恢复默认主题
jt -r
-
效果
-
添加如下样式信息【 C:\Users\coderitl\.jupyter\custom
】
-
-
样式添加
.CodeMirror pre {
font-family: Consolas;
font-size: 12pt;
}
* {
font-family: Consolas;
}
div.output_area pre {
font-family: Consolas;
font-size: 12pt;
}
div.input_prompt {
font-family: Consolas;
font-size: 12pt;
}
div.out_prompt_overlay {
font-family: Consolas;
font-size: 12pt;
}
div.prompt {
font-family: Consolas;
font-size: 12pt;
}
span.cm-comment {
font-family: Consolas !important;
font-style: normal !important;
color: #BB3D00 !important;
}
-
onedork
配置后效果展示 -
monokai
主题
jt -t monokai -T -N -fs 13 -f consolamono
-
效果图
-
配置快捷提示【 在anaconda
中的jupyter
扩展不会显示】
# anaconda 会默认拥有网页版 jupyter 扩展选中插件
python -m pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user --skip-running-check
作者介绍
ㅤcoderitl
V1