jupyter notebook 远程访问配置

jupyter notebook/lab 远程访问配置

  1. 运行命令,生成jupyter notebook的配置文件
jupyter notebook --generate-config
jupyter lab --generate-config

得到结果:

Writing default config to: /home/*YOURUSERNAME*/.jupyter/jupyter_notebook_config.py
Writing default config to: /home/*YOURUSERNAME*/.jupyter/jupyter_lab_config.py

虽然配置notebook后,lab会默认使用notebook的配置,但是会报警,强迫症表示受不了,就生成一份吧!
如下的配置基本一样,只不过lab对应的是c.ServerApp.配置的属性是相同的。

  1. 打开Python/Ipython shell,运行
from notebook.auth import passwd;passwd()

或者直接在bash中运行:

python -c "from notebook.auth import passwd;print(passwd())"

会生成一串’type:salt:hashed-password’格式的哈希密码,复制一下,后面要添加到配置文件中。

注意,最近在进行配置的时候,上面的方法在lab没有成功,暂时没有进一步研究是哪一个地方出问题了,解决方式是直接在打开的时候指定token:

jupyter lab --ServerApp.token="yourpassword"
  1. 打开jupyter 配置文件
import webbrowser 
webbrowser.register( "chrome", None, webbrowser.GenericBrowser("your\chrome\path\chrome.exe"))

## The port the notebook server will listen on.
c.NotebookApp.port = 0000
#  The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = 'the hashed password string'
## Whether to open in a browser after starting. The specific browser used is
#  platform dependent and determined by the python standard library `webbrowser`
#  module, unless it is overridden using the --browser (NotebookApp.browser)
#  configuration option.
#c.NotebookApp.open_browser = False
c.NotebookApp.browser = 'chrome'
## Dict of Python modules to load as notebook 

## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = '/home/ubuntu/jupyter'
## The IP address the notebook server will listen on.
c.NotebookApp.ip = '*'

c.NotebookApp.allow_root = True

## Supply overrides for terminado. Currently only supports "shell_command".
#  Default: {}
# linux环境下,指定“/bin/bash”
# win10环境下,要指定路径,此处bash.exe已经添加到环境变量中
c.ServerApp.terminado_settings = {"shell_command":"bash.exe"}

或者直接粘贴:

c.NotebookApp.ip = '*'
c.NotebookApp.port = 0000
c.NotebookApp.password = 'the hashed password string'
c.NotebookApp.notebook_dir = '/home/ubuntu/jupyter'
c.NotebookApp.open_browser = False
c.NotebookApp.allow_root = True
  1. 运行jupyter notebook,会显示ip及port。输入浏览器,即可出现登陆界面,输入密码即可。
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值