访问局域网里的juypterlab

· 462 words · 1 minute read

在局域网里的树莓派上装了juypterlab

pip install jupyterlab

应对jupyterlab进行设置,创建它的配置文件

jupyter-lab --generate-config

此时在用户目录下.jupyter下生成了一个配置文件jupyter_lab_config.py 编辑它

vim /home/pi/.jupyter/jupyter_lab_config.py

找到c.ServerApp.allow_origin 设置为’*’,表示允许从任意地方远程访问, 也可以设置为’192.168.3.2’,表示只能由使用’192.168.3.2’这个IP的主机对Jupyterlab发起访问,设置完后去掉行首注释符#

c.ServerApp.allow_origin = '*'

找到c.ServerApp.ip 设置为树莓派的IP地址192.168.3.20,设置完后去掉行首注释符#

c.ServerApp.ip = '192.168.3.20'

Code language: JavaScript (javascript) 然后输入 jupyter-lab 启动服务端(后台运行的话,可以在tmux里运行jupyter-lab),这是命令行会打印出web页面的访问网址,不能只访问192.168.3.20:8888,也要把后边的token带上,不然进入不去jupyterlab的,第一次访问后会生成cookie, 下次访问的时候可以直接192.168.3.20:8888,不用带后边token了

http://192.168.3.20:8888/lab?token=2a64158e6ebf9c1842fd54b7d1edde6c122db201baac8e769
http://127.0.0.1:8888/lab?token=2a64158e6ebf9c1842fd54b7d1edde6c122db201baac8e769