【工具】远程服务器Jupyter安装及访问

1 安装Jupyter

# 更新pip3到最新版本
pip3 install --upgrade pip
# pip安装jupyter notebook
pip3 install jupyter notebook

2 生成配置文件

jupyter notebook --generate-config

writing default config to : /your_root_path/.jupyter/jupyter_notebook_config.py

3 创建密码

jupyter notebook password

自动把生成含有密码的 hash 码输入到jupyter_notebook_config.json文件
/your_root_path/.jupyter/jupyter_server_config.json

4 修改配置文件

vim jupyter/jupyter_notebook_config.py

在文件末尾添加:

c.NotebookApp.allow_remote_access = True #是否允许远程访问,默认False
c.NotebookApp.allow_root = True #是否同意jupyter以root身份运行,默认False
c.NotebookApp.ip = '0.0.0.0' #允许所有ip访问
c.NotebookApp.notebook_dir = '/www/algorithm/agent' #自定义工作区,目录要自己预先创建。
c.NotebookApp.open_browser = False #是否在键入jupyter时打开浏览器
c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=xxxxxxxxxxxxx' #jupyter server密码,从jupyter_notebook_config.json 复制出来。
c.NotebookApp.port = 8502 #jupyter的监听端口,默认8888

需要修改的内容:
1 自定义工作区 :推荐与ipynb所有目录一致
2 jupyter server 密码,从jupyter_notebook_config.json 复制出来。
3 自定义监听端口

5 启动 jupyter notebook

jupyter notebook
#jupyter notebook --ip=0.0.0.0 --port=8888
# 或使用nohup后台运行
nohup jupyter notebook &

6 远程访问 jupyter notebook

http://127.0.0.1:port/

posted @ 2024-08-15 11:28  NS-5  阅读(144)  评论(0)    收藏  举报