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
原因:
- 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
- 有另一种说法是端口被占用之类的
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