简体   繁体   English

jupyter lab 的全新 conda 安装无法连接到 kernel

[英]Fresh conda installation of jupyter lab cannot connect to kernel

I'm trying to run jupyter lab with miniconda, but Jupyter is having trouble connecting with the kernel. Below is some background info, the steps I've done, and the code that results.我正在尝试使用 miniconda 运行 jupyter lab,但 Jupyter 在连接 kernel 时遇到问题。下面是一些背景信息、我完成的步骤以及生成的代码。

Background Info背景资料

  • I have been successfully using jupyter lab for months.我已经成功使用 jupyter lab 几个月了。
  • It was only today that this problem started occurring.直到今天,这个问题才开始出现。
    • I suspected that this is related to the fact that I installed XCode Command Line Tools 13 this morning, which was only released yesterday, but the same problem occurred after a downgrade to 12.5.1.我怀疑这与我今天早上安装了XCode Command Line Tools 13有关,昨天才发布,但是降级到12.5.1后出现同样的问题。
  • I am using miniconda.我正在使用迷你康达。

Steps脚步

  • Create a fresh conda environment创造一个新鲜的conda环境
  • Activate it with conda activate test使用conda activate test激活它
  • I then run conda install jupyterlab然后我运行conda install jupyterlab
  • After installation, I run jupyter lab to open the browser and navigate to my .ipynb安装后,我运行jupyter lab打开浏览器并导航到我的.ipynb

Now, the bottom left corner of the browser reads "Python 3 (ipykernel) | Connecting", which doesn't say much.现在,浏览器左下角写着“Python 3 (ipykernel) | Connecting”,没什么好说的。 Here's a summary of the logs:以下是日志摘要:

Regular log output常规日志 output

There's the initial info (which I don't think contains anything novel, but may help to answer some questions you might have that I haven't thought of):这是初步信息(我认为它不包含任何新颖的内容,但可能有助于回答您可能有但我没有想到的一些问题):

[I 2021-09-21 09:36:33.353 ServerApp] jupyterlab | extension was successfully linked.
[I 2021-09-21 09:36:34.278 ServerApp] nbclassic | extension was successfully linked.
[I 2021-09-21 09:36:34.509 LabApp] JupyterLab extension loaded from /opt/miniconda3/envs/test/lib/python3.9/site-packages/jupyterlab
[I 2021-09-21 09:36:34.509 LabApp] JupyterLab application directory is /opt/miniconda3/envs/test/share/jupyter/lab
[I 2021-09-21 09:36:34.515 ServerApp] jupyterlab | extension was successfully loaded.
[I 2021-09-21 09:36:34.526 ServerApp] nbclassic | extension was successfully loaded.
[I 2021-09-21 09:36:34.527 ServerApp] Serving notebooks from local directory: /Users/connorpancoast/Code/grassmaNN
[I 2021-09-21 09:36:34.527 ServerApp] Jupyter Server 1.4.1 is running at:
[I 2021-09-21 09:36:34.527 ServerApp] http://localhost:8888/lab?token=fa21e773398a0c8bbeccdb7a67ffb20950bac831209b9373
[I 2021-09-21 09:36:34.527 ServerApp]  or http://127.0.0.1:8888/lab?token=fa21e773398a0c8bbeccdb7a67ffb20950bac831209b9373
[I 2021-09-21 09:36:34.527 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2021-09-21 09:36:34.535 ServerApp]

    To access the server, open this file in a browser:
        file:///Users/connorpancoast/Library/Jupyter/runtime/jpserver-24903-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=fa21e773398a0c8bbeccdb7a67ffb20950bac831209b9373
     or http://127.0.0.1:8888/lab?token=fa21e773398a0c8bbeccdb7a67ffb20950bac831209b9373

After this is when things get strange.这之后事情就变得奇怪了。

Strange log output奇怪的日志 output

First is this warning about nodejs , which may or may not be important.首先是关于nodejs的警告,它可能重要也可能不重要。

[W 2021-09-21 09:36:39.621 LabApp] Could not determine jupyterlab build status without nodejs
/opt/miniconda3/envs/test/lib/python3.9/json/encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
  return _iterencode(o, 0)

Next, the kernel starts, but there's a connection timeout.接下来,kernel 启动,但出现连接超时。

[I 2021-09-21 09:36:51.114 ServerApp] Kernel started: b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[W 2021-09-21 09:37:51.549 ServerApp] Timeout waiting for kernel_info reply from b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[W 2021-09-21 09:37:56.092 ServerApp] Nudge: attempt 10 on kernel b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[W 2021-09-21 09:37:56.093 ServerApp] Nudge: attempt 10 on kernel b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[W 2021-09-21 09:37:56.109 ServerApp] Nudge: attempt 10 on kernel b38270f5-9a72-42cf-86e5-0e8e4b3b9514

I'm unsure why three separate "nudge processes" are occurring, but after 120 nudge attempts (shown), this error message also appears three times, not shown for space:我不确定为什么会发生三个单独的“轻推过程”,但在 120 次轻推尝试后(如图所示),此错误消息也出现了三次,未显示空间:

[W 2021-09-21 09:38:51.474 ServerApp] Nudge: attempt 120 on kernel b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[W 2021-09-21 09:38:51.475 ServerApp] Nudge: attempt 120 on kernel b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[W 2021-09-21 09:38:51.476 ServerApp] Nudge: attempt 120 on kernel b38270f5-9a72-42cf-86e5-0e8e4b3b9514
[E 2021-09-21 09:38:51.558 ServerApp] Uncaught exception GET /api/kernels/b38270f5-9a72-42cf-86e5-0e8e4b3b9514/channels?session_id=f834b0b3-b8ed-4b2d-bfc9-7a535593a24f (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kernels/b38270f5-9a72-42cf-86e5-0e8e4b3b9514/channels?session_id=f834b0b3-b8ed-4b2d-bfc9-7a535593a24f', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "/opt/miniconda3/envs/test/lib/python3.9/site-packages/tornado/websocket.py", line 956, in _accept_connection
        await open_result
    tornado.util.TimeoutError: Timeout

After those, these appear:在那些之后,这些出现:

[W 2021-09-21 09:39:21.571 ServerApp] WebSocket ping timeout after 90003 ms.
[W 2021-09-21 09:39:21.585 ServerApp] WebSocket ping timeout after 90003 ms.
[W 2021-09-21 09:42:51.594 ServerApp] Replacing stale connection: b38270f5-9a72-42cf-86e5-0e8e4b3b9514:ee46fa70-0af0-489d-8993-acf4f55bf3aa
[W 2021-09-21 09:42:52.123 ServerApp] Replacing stale connection: b38270f5-9a72-42cf-86e5-0e8e4b3b9514:ee46fa70-0af0-489d-8993-acf4f55bf3aa
/opt/miniconda3/envs/test/lib/python3.9/json/encoder.py:257: UserWarning: date_default is deprecated since jupyter_client 7.0.0. Use jupyter_client.jsonutil.json_default.
  return _iterencode(o, 0)
[I 2021-09-21 09:46:52.126 ServerApp] Starting buffering for b38270f5-9a72-42cf-86e5-0e8e4b3b9514:ee46fa70-0af0-489d-8993-acf4f55bf3aa
[W 2021-09-21 09:46:52.146 ServerApp] Replacing stale connection: b38270f5-9a72-42cf-86e5-0e8e4b3b9514:f834b0b3-b8ed-4b2d-bfc9-7a535593a24f
[W 2021-09-21 09:46:55.306 ServerApp] Replacing stale connection: b38270f5-9a72-42cf-86e5-0e8e4b3b9514:1db7c82b-2627-4c43-b9d3-da7bef15ca32

I also use Jupyter Lab with Miniconda, and this is what I did a few days ago.我还将 Jupyter Lab 与 Miniconda 一起使用,这是我几天前所做的。

It seems that you need the install node.js and ipykernel with:看来您需要安装 node.js 和 ipykernel:

conda install nodej ipykernel

Also, I read somewhere that you need to "tell" Jupyter Lab to use your environment as follow:另外,我在某处读到你需要“告诉”Jupyter Lab 使用你的环境,如下所示:

python -m ipykernel install --user --name test --display-name “enviroment_test”

Note that test is your environment name, and “enviroment_test” is the name that it will show in Jupyter.请注意, test是您的环境名称, “enviroment_test”是它将在 Jupyter 中显示的名称。

Finally, I would suggest installing Jupyter from conda-forge with:最后,我建议使用以下命令从 conda-forge 安装 Jupyter:

conda install jupyterlab -c conda-forge

Obs.: all this need to be done with your desired environment activated观察:所有这些都需要在激活所需环境的情况下完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM