本地使用服务器jupyter lab

Q1: 为什么不是使用jupyter notebook?

A1: 人家(jupyter notebook 官方) 说了 jupyter lab 是notebook 的增强版

Q2: 完整的配置过程分为几大步骤?

A2:


## i 服务器安装jupyter lab
conda install -c conda-forge jupyterlab

ii 配置jupyter lab 可以远程使用

1 生成秘钥

$ ipython
Python 3.7.11 (default, Jul 27 2021, 14:32:16) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.26.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:from IPython.lib import passwd
In [2]:passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:xxx:xxxx'
In [3]: exit()

这里我设置的密码为空,所以直接回车,登录的时候也是直接回车登录

2 生成配置文件

$ jupyter lab --generate-config
Writing default config to: /home/username/.jupyter/jupyter_lab_config.py
$ vim /home/username/.jupyter/jupyter_lab_config.py

3 修改配置文件
在文件的最下面增加就好,当然也可直接对配置文件的每一项进行修改(但是好长的文件,不如直接来个最简单的方法)

$ vim /home/usrname/.jupyter/jupyter_lab_config.py

c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha1:xxx:xxxx'
c.NotebookApp.open_browser = False
c.NotebookApp.port =8889

iii 远程登录

服务器终端输入

$ jupyter lab

然后尝试本地浏览器直接访问服务器ip:port 的方式,如果可以那就ok。
否则:无法访问 出现502 那就是服务器拒绝了
需要在本地终端输入

ssh username@ip -L 127.0.0.1:本地端口:127.0.0.1:服务器端口

也可以使用

ssh username@ip -L 本地端口:127.0.0.1:服务器端口

再次以服务器ip:port 的方式访问
只能帮到这里了,如果再出现问题,我也没辙了。

10月15日增:
遇到问题:
channel 2: open failed: connect failed: Connection refused
原因:
  1. Google搜索了一下,以下网站网友说是服务器localhost配置问题
https://serverfault.com/questions/489192/ssh-tunnel-refusing-connections-with-channel-2-open-failed
https://superuser.com/questions/346971/ssh-tunnel-connection-refused
  1. 有另一种说法是端口被占用之类的
https://blog.csdn.net/bluehatihati/article/details/113891910
解决:

但是以前用都没有问题,现在使用相同的命令却有了问题,排除原因1
服务区端口换一个使用,比如我换成9999,okay,正常了… …

10月20日增:
问题:
channel 2: open failed: connect failed: Connection refused

上面两种原因都排除之后依然出现了这种情况,又Google了一下,终于找到另外可能的原因和对应的解决方案
原因:ssh自动定时终止连接
解决:那么通过配置文件实现始终与服务器相连接

sudo vim /etc/ssh/ssh_config
    TCPKeepAlive=yes
    ServerAliveInterval 60
    ServerAliveCountMax 3

引用地址 https://www.jianshu.com/p/d68b1bf3fc95

总结一下就是,首先保证服务器端启动了jupyter lab

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值