2 分钟
Jupyter Notebook使用教程
一、安装
1、使用Anaconda的conda安装
完成后,Jupyter自动安装完毕
2、pip安装
pip3 install --upgrade pip
pip3 install jupyter二、服务器安全配置
1、默认运行和命令行参数
(1)运行
如果是本地使用,直接运行
jupyter notebook他会在默认浏览器打开 http://localhost:8888
持久化运行
nohup jupyter notebook &关闭
ps -ef|grep jupyter
kill -9 +进程号(2)命令行参数
jupyter notebook --port 9999 #指定运行端口
jupyter notebook --no-browser #后台运行不开浏览器
jupyter notebook --help #获得帮助2、配置登录密码和证书
centos6.5环境
(1)生成配置文件
jupyter notebook --generate-config(2)生成密码信息
ipython
from notebook.auth import passwd
passwd()
# 输出类似于 sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed 字符串将其记录
(3)获取证书
没有ssl证书临时生成
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mykey.key -out mycert.pem或者去云服务平台申请免费证书,例如腾讯云ssl
(4)编辑配置文件
# 配置密码
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
# 配置证书目录
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key'
# 登录ip全部允许
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False #开启服务不打开服务器
# 设置访问端口
c.NotebookApp.port = 9999三、其他配置
(1)安装Jupyter插件管理器
conda install -c conda-forge jupyter_contrib_nbextensions(2)安装jupyterlab
conda install -c conda-forge jupyterlab运行
jupyter lab(3)修改默认工作空间
# 打开配置文件
c.NotebookApp.notebook_dir = ''四、使用指南
1、快捷键
Shift-Enter: run cellCtrl-Enter: run cell in-placeAlt-Enter: run cell, insert belowEscandEnter: Command mode and edit mode
2、更换主题字体
(1)更换主题
安装主题插件
pip install --upgrade jupyterthemes -i https://pypi.tuna.tsinghua.edu.cn/simple查看主题列表
jt -l更换主题
jt -t onedork -T -N重启
ps aux | grep jupyter
kill -9 xxx
nohup /root/anaconda3/bin/jupyter notebook --allow-root &(2)更换字体
vim ~/.jupyter/custom/custom.css输入以下命令:替换所有行第一个monospace为consolas
:1,$s/monospace/consolas3、安装其他内核
ipython kernel install --name python2