Ubuntu远程部署及访问jupyter

一、Ubuntu下安装jupyter notebook

# 创建虚拟环境
conda create -n myjupyter python=3.9
# 激活虚拟环境
conda activate myjupyter
# 安装jupyter
pip install jupyter

二、Jupyter notebook配置

1、生成配置文件

jupyter notebook --generate-config

2.修改jupyter notebook的配置文件

  • 打开配置文件
vi ~/.jupyter/jupyter_notebook_config.py
  • 在该文件中做如下修改或直接在文件尾端添加:
c.NotebookApp.allow_origin = '*'
c.NotebookApp.allow_remote_access = True
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
c.NotebookApp.notebook_dir = '/mnt/xxx/jupyters'   # 设置jupyter文件存储目录

3.设置密码

jupyter notebook password

4.启动jupyter notebook

 nohup jupyter notebook --allow-root >./jupyter.log 2>&1 &

三、本地访问

  • 通过设置 SSH,通过 SSH 从远程计算机访问jupyter:
# 将 <PORT> 替换为上述步骤中设置的端口号
# 将 <REMOTE_USER> 替换为远程服务器用户名
# 将 <REMOTE_HOST> 替换为您的远程服务器地址
ssh -L 8080:localhost:<PORT> <REMOTE_USER>@<REMOTE_HOST>
  • 从本地计算机打开浏览器访问http://localhost:8080/并导航到 Jupyter Notebook。

猜你喜欢

转载自blog.csdn.net/ylfmsn/article/details/129957736