升级到jupyter lab 3之后原来的password无法登陆解决方法

  1. jupyter-lab 2使用jupyter_notebook_config.py配置文件进行密码设置的操作为:

/opt/pyenvs/envtf22/bin/ipython

Python 3.6.8 (default, Nov 16 2020, 16:55:22)

Type 'copyright', 'credits' or 'license' for more information

IPython 7.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [3]: from notebook.auth import passwd; passwd("heheda")

Out[3]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$Ktjc9LqcZ7WxFPcjp8SFlQ$oKAMhUstb80LAsEFROzD9A'

vim jupyter_notebook_config.py

# 将 c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$Ktjc9LqcZ7WxFPcjp8SFlQ$oKAMhUstb80LAsEFROzD9A'
# 加入jupyter_notebook_config.py中

# 启动jupyter-lab

nohup /opt/pyenvs/envtf22/bin/jupyter-lab --config='./jupyter/jupyter_notebook_config.py' &>./jupyter_lab_log.txt &

  1. 当升级到jupyter-lab3之后,发现使用原来的jupyter_notebook_config.py配置文件进行启动时会有一些告警,并且使用密码无法登陆,同时又没有token在启动日志中打印。

[W 2021-03-03 13:16:31.025 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.

[W 2021-03-03 13:16:31.026 LabApp] 'ip' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.

[W 2021-03-03 13:16:31.026 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.

[W 2021-03-03 13:16:31.026 LabApp] 'notebook_dir' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.

[W 2021-03-03 13:16:31.026 LabApp] 'password' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.

[W 2021-03-03 13:16:31.026 LabApp] 'port' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.

[W 2021-03-03 13:16:31.037 ServerApp] notebook_dir is deprecated, use root_dir

[I 2021-03-03 13:16:31.037 ServerApp] jupyterlab | extension was successfully linked.

[I 2021-03-03 13:16:31.500 ServerApp] nbclassic | extension was successfully linked.

[W 2021-03-03 13:16:31.542 ServerApp] WARNING: The Jupyter server is listening on all IP addresses and not using encryption. This is not recommended.

[I 2021-03-03 13:16:31.549 LabApp] JupyterLab extension loaded from /opt/pyenvs/envtf22/lib/python3.6/site-packages/jupyterlab

[I 2021-03-03 13:16:31.549 LabApp] JupyterLab application directory is /opt/pyenvs/envtf22/share/jupyter/lab

[I 2021-03-03 13:16:31.555 ServerApp] jupyterlab | extension was successfully loaded.

[I 2021-03-03 13:16:31.561 ServerApp] nbclassic | extension was successfully loaded.

[I 2021-03-03 13:16:31.561 ServerApp] 启动notebooks 在本地路径: /home

[I 2021-03-03 13:16:31.562 ServerApp] Jupyter Server 1.4.1 is running at:

[I 2021-03-03 13:16:31.562 ServerApp] http://bg1:1288/lab

[I 2021-03-03 13:16:31.562 ServerApp]  or http://127.0.0.1:1288/lab

[I 2021-03-03 13:16:31.562 ServerApp] 使用control-c停止此服务器并关闭所有内核(两次跳过确认).

[W 2021-03-03 13:16:31.570 ServerApp] 没有找到web浏览器: could not locate runnable browser.

[I 2021-03-03 13:16:48.118 LabApp] 302 GET /lab (192.168.10.97) 2.26ms

[W 2021-03-03 13:16:51.500 ServerApp] 401 POST /login?next=%2Flab (192.168.10.97) 3.18ms referer=http://192.168.0.15:1288/login?next=%2Flab

[W 2021-03-03 13:17:08.944 ServerApp] 401 POST /login?next=%2Flab (192.168.10.97) 3.24ms referer=http://192.168.0.15:1288/login?next=%2Flab

image
  1. 解决方法

# 将配置文件中使用到的.NotebookApp修改为.ServerApp,如:

# 将 c.NotebookApp.open_browser = False 修改为:

c.ServerApp.open_browser = False

  1. 这只能解决告警问题,永久修改密码并保存到配置文件中,还需要继续以下操作:

# shell中输入jupyter-lab password,设置jupyter-lab密码

jupyter-lab password

image

cat /root/.jupyter/jupyter_server_config.json

{

  "ServerApp": {

    "password": "sha1:7f28388e8a7b:ebc342bc6d7eefed08912d7edf6d364751c97c41"

  }

}

将 c.ServerApp.password = "sha1:7f28388e8a7b:ebc342bc6d7eefed08912d7edf6d364751c97c41"
替换jupyter_notebook_config.py中原来的密码配置。

  1. 启动jupyter-lab3
nohup /opt/pyenvs/envtf22/bin/jupyter-lab --config='./jupyter/jupyter_notebook_config.py' &>./jupyter_lab_log.txt &
  1. 查看启动日志
tail -100 ./jupyter_lab_log.txt

[W 2021-03-03 13:02:01.421 ServerApp] notebook_dir is deprecated, use root_dir
[I 2021-03-03 13:02:01.454 ServerApp] jupyterlab | extension was successfully linked.
[I 2021-03-03 13:02:01.904 ServerApp] nbclassic | extension was successfully linked.
[W 2021-03-03 13:02:01.947 ServerApp] WARNING: The Jupyter server is listening on all IP addresses and not using encryption. This is not recommended.
[I 2021-03-03 13:02:01.953 LabApp] JupyterLab extension loaded from /opt/pyenvs/envtf22/lib/python3.6/site-packages/jupyterlab
[I 2021-03-03 13:02:01.953 LabApp] JupyterLab application directory is /opt/pyenvs/envtf22/share/jupyter/lab
[I 2021-03-03 13:02:01.960 ServerApp] jupyterlab | extension was successfully loaded.
[I 2021-03-03 13:02:01.967 ServerApp] nbclassic | extension was successfully loaded.
[I 2021-03-03 13:02:01.967 ServerApp] 启动notebooks 在本地路径: /home
[I 2021-03-03 13:02:01.967 ServerApp] Jupyter Server 1.4.1 is running at:
[I 2021-03-03 13:02:01.967 ServerApp] http://bg1:1207/lab
[I 2021-03-03 13:02:01.967 ServerApp]  or http://127.0.0.1:1207/lab
[I 2021-03-03 13:02:01.967 ServerApp] 使用control-c停止此服务器并关闭所有内核(两次跳过确认).
[W 2021-03-03 13:02:01.976 ServerApp] 没有找到web浏览器: could not locate runnable browser.
[I 2021-03-03 13:02:10.521 ServerApp] 302 POST /login?next=%2Flab%3F (192.168.10.97) 5.75ms
[I 2021-03-03 13:02:15.620 LabApp] Build is up to date
[I 2021-03-03 13:02:47.500 ServerApp] Kernel started: 368e649f-5429-476b-a21c-f03521d55c29
[I 2021-03-03 13:03:35.396 LabApp] 302 GET /lab (192.168.10.97) 1.97ms
[I 2021-03-03 13:03:42.776 ServerApp] 302 POST /login?next=%2Flab (192.168.10.97) 3.18ms
[I 2021-03-03 13:03:47.905 LabApp] Build is up to date
[I 2021-03-03 13:44:04.531 ServerApp] Starting buffering for 368e649f-5429-476b-a21c-f03521d55c29:dd931da2-18ce-43f4-96c3-03fffdba796a
[I 2021-03-03 13:44:08.759 LabApp] Build is up to date

image.png

你可能感兴趣的:(升级到jupyter lab 3之后原来的password无法登陆解决方法)