安装jupyter notebook
pip install jupyter notebook
将jupyter notebook 加入环境变量
即将python所在的bin目录 /usr/local/python3/bin 添加到环境变量
参考:Linux环境变量配置全攻略 - 悠悠i - 博客园
生成配置文件
jupyter notebook --generate-config
配置密码
# 进入Python
from notebook.auth import passwd
passwd() # 随后设置密码
修改配置文件
vim /root/.jupyter/jupyter_notebook_config.py
编辑如下配置:
c.NotebookApp.password = '刚刚生成的密钥'c.NotebookApp.ip = '0.0.0.0'c.NotebookApp.open_browser = Falsec.NotebookApp.port = 8888c.NotebookApp.notebook_dir = 'xxx' # 工作目录
修改完毕之后按一下ESC,并输入:wq
按回车退出
当前窗口运行
jupyter notebook --allow-root
后台运行
nohup jupyter notebook --allow-root >/dev/null 2>&1 &
随系统启动
编辑/etc/rc.local文件:
vi /etc/rc.local
在文件里面添加启动代码如下:
nohup jupyter notebook --allow-root >/dev/null 2>&1 &