Jupyter Notebook
Jupyter Notebook / jupyterlab
Categories:
Linux服务器上搭建jupyter notebook / jupyterlab
安装基础软件
1pip install ipython jupyter
2pip install jupyterlab
生成配置文件
jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
jupyter lab --generate-config
生成秘钥
1# ipython
2In [1]: from notebook.auth import passwd
3In [2]: passwd()
4Enter password:
5Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$Sunk/A1dg/SA'
编辑配置文件
c.NotebookApp.ip = '*' # 对外提供访问的ip
c.NotebookApp.port = 8888 # 对外提供访问的端口
c.NotebookApp.open_browser = False # 启动不打开浏览器
c.NotebookApp.password = 'sha1:f8b5f5dbeca8:d1f5b93d5e787e4bf1bf4ad2c48c177ba79f55dd' # 上面生成的秘钥
c.NotebookApp.notebook_dir = '/root/jupyter_dir' # 设置jupyter启动后默认文件夹
c.NotebookApp.allow_root = True # 允许root用户执行
插件安装
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
pip install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
pip install jupyterthemes
jt -l # 列出可选的主题
# -f(字体) -fs(字体大小) -cellw(占屏比或宽度) -ofs(输出段的字号) -T(显示工具栏) -N(显示自己主机名)
jt -t monokai -f fira -fs 9 -ofs 9 -dfs 9 -T -N
后台运行
nohup jupyter notebook &>./jupyter.log &
nohup jupyter lab --allow-root &>./jupyter.log &
重启脚本
rejn(){
pid=$(ps aux | grep jupyter-notebook | grep -v 'grep' | awk '{print $2}')
kill -9 ${pid}
nohup jupyter notebook &>./jupyter.log &
}
rejl(){
pid=$(ps aux | grep jupyter-lab | grep -v 'grep' | awk '{print $2}')
kill -9 ${pid}
nohup jupyter lab --allow-root &>./jupyterlab.log &
}