安装
pip install jupyter
运行
jupyter notebook

我是在home/shanghaimei/notebook目录下运行的,所以打开是在当前目录下,创建的文件也在这个文件夹下

创建新的文件,这里我选择的是python3

点击untitled可以重命名

设置好后就可以写代码了
可选择要输入的类型

按Shift+Enter可以向下运行

Ctrl + S 快捷键保存文档,默认是保存为ipynb,保存在你终端进入的当前目录下
如果不想保存默认的格式,可以在file里的Download as里选择(Ubuntu截图不大方便,可自己查看)

如果想下载PDF,出错的话先安装
sudo apt-get install texlive-xetex
然后下载PDF就可以了,很漂亮的!
关于jupyter的各种快捷键
在help的keyboard shortcuts中,可自定义

用的时候遇到了一个问题,平时用scrapy虚拟环境,但是打开jupyter后并没有这个虚拟环境,只有本机上的,解决办法如下:
shanghaimei@shanghaimei:~/notebook$ mkvirtualenv scrapy
shanghaimei@shanghaimei:~/notebook$ workon scrapy
(scrapy) shanghaimei@shanghaimei:~/notebook$ pip install ipykernel
(scrapy) shanghaimei@shanghaimei:~/notebook$ python -m ipykernel install --user --name scrapy --display-name "Python3(scrapy)"
#display-name "可自定义"
安装后重启
(scrapy) shanghaimei@shanghaimei:~/notebook$ jupyter notebook
如图,虚拟环境添加上了

常用快捷键
Enter : 转入编辑模式
Shift-Enter : 运行本单元,选中下个单元
Ctrl-Enter : 运行本单元
Alt-Enter : 运行本单元,在其下插入新单元
Y : 单元转入代码状态
M :单元转入markdown状态
R : 单元转入raw状态
A : 在上方插入新单元
B : 在下方插入新单元
X : 剪切选中的单元
C : 复制选中的单元
Shift-V : 粘贴到上方单元
V : 粘贴到下方单元
Z : 恢复删除的最后一个单元
D,D : 删除选中的单元
Shift-M : 合并选中的单元
网友评论