MENU

服务器配置jupyter

September 2, 2021 • Read: 502 • 杂谈阅读设置

服务器环境

阿里云

配置

安装依赖,虚拟环境更好

pip3 install jupyter

进入ipython交互界面获取配置文件所需密码

from notebook.auth import passwd

passwd()

配置文件生成与修改

jupyter notebook --generate-config
vim  /root/.jupyter/jupyter_notebook_config.py

参数设置

c.NotebookApp.ip='0.0.0.0'                         # 设置所有ip都可以访问
c.NotebookApp.password ='argon2:$ar...'            # 之前得到的密文密码
c.NotebookApp.open_browser = False                 #  禁止自动打开浏览器
c.NotebookApp.port =9999                          # 服务启动的端口,随便设
c.NotebookApp.allow_root = True                    #不用在启动时加--allow-root
c.NotebookApp.notebook_dir = "/usr/jupyter_files"  #配置启动目录

启动

jupyter notebook

nohup jupyter notebook --allow-root &  #关闭终端后还能运行
#其中nohup表示不挂断地运行命令、 &表示在后台运行 一般两个一起用nohup command &

关闭

ps -aux|grep jupyter-notebook    #查找进程号
kill -9 PID  

插件安装

pip3 install jupyter_contrib_nbextensions
jupyter contrib nbextension install
pip3 install jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable 
jupyter nbextension enable

其它

注意服务器安全组配置以及防火墙放行 开放端口

Last Modified: November 9, 2021