Jupyter远程服务器设置

Jupyter远程服务器设置

此文来自 Jupyter 开启远程服务器

最近在做 AI 方面的研究,用到了 python。使用python编辑器或者vim 在遇到输入错误需要重新输入的时候,会感觉很别扭,尤其是在 for 循环等中。而 jupyter 可以实现文本编辑并运行的效果,对我而言提高了效率。

安装 Jupyter

pip install notebook jupyterlab

设置密码

自动设置

$  jupyter server password
Enter password:  ****
Verify password: ****
[JupyterPasswordApp] Wrote hashed password to /Users/you/.jupyter/jupyter_server_config.json

手动设置
打开python,输入以下语句:

from jupyter_server.auth import passwd
passwd()
Enter password:
Verify password:
'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

生成配置文件

$  jupyter server --generate-config
Writing default config to: /root/.jupyter/jupyter_server_config.py

修改配置文件

打开 jupyter_notebook_config.py, 修改里面的:

c.ServerApp.allow_remote_access = True
c.ServerApp.allow_root = True
# 开启远程访问ip
c.ServerApp.ip = '*'
c.ServerApp.open_browser = False
c.ServerApp.password_required = True
# 使用自动设置密码,则此处不需要配置手动密码
c.ServerApp.password = ''
设置端口号
c.ServerApp.port = 9999
# notebook存储目录
c.ServerApp.notebook_dir = '/root/app/jupyter'

启动Jupyter

在命令行输入 jupyter notebook就可以开启服务了。但我们一般希望Jupyter Notebook在后台运行,所以可以输入以下命令

$ nohup jupyter notebook --allow-root >/dev/null 2>&1 &
启动juypterlab:
$ nohup jupyter lab --allow-root >/dev/null 2>&1 &

因为 jupyterlab中包含jupyter notebook, 所以启动jupyterlab,则同时也启动了jupyter notebook.

参考文档

Jupyter 开启远程服务器(最新版)

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值