Jupyter notebook 不连接内核(2) - conda + mc os 11.5 + appnope

Jupyter notebook does not connect to kernel(2) - conda + mc os 11.5 + appnope

我正在努力 mac os 11.5!

我用conda创建了一个虚拟环境并激活了它:

conda create -n myenv python=3.6

conda activate myenv

我尝试在这个新环境中安装 jupyter notebook:

conda install jupyter notebook

一切顺利!现在我启动它,它尝试连接到内核 1 分钟,没有成功并且 returns 错误!

我得到的错误(我只是复制最后几行,因为 Whosebug 不允许我 pos 太多代码):


Traceback (most recent call last):
.
.
.
  File "~/opt/anaconda3/envs/myenv/lib/python3.6/site-packages/appnope/_nope.py", line 60, in beginActivityWithOptions
    NSProcessInfo = C('NSProcessInfo')
  File "~/opt/anaconda3/envs/myenv/lib/python3.6/site-packages/appnope/_nope.py", line 38, in C
    assert ret is not None, "Couldn't find Class %s" % classname
AssertionError: Couldn't find Class NSProcessInfo
[W 16:03:16.833 NotebookApp] KernelRestarter: restart failed
[W 16:03:16.834 NotebookApp] Kernel 23590965-8381-42a0-ab03-f81495576942 died, removing from map.
[W 16:04:01.865 NotebookApp] Timeout waiting for kernel_info reply from 23590965-8381-42a0-ab03-f81495576942
[E 16:04:01.868 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 23590965-8381-42a0-ab03-f81495576942)
[W 16:04:02.892 NotebookApp] 404 GET /api/kernels/23590965-8381-42a0-ab03-f81495576942/channels?session_id=fef577101b6a43d781a438c90d50d561 (::1): Kernel does not exist: 23590965-8381-42a0-ab03-f81495576942
[W 16:04:02.905 NotebookApp] 404 GET /api/kernels/23590965-8381-42a0-ab03-f81495576942/channels?session_id=fef577101b6a43d781a438c90d50d561 (::1) 15.490000ms referer=None
[W 16:04:04.917 NotebookApp] Replacing stale connection: 23590965-8381-42a0-ab03-f81495576942:fef577101b6a43d781a438c90d50d561
[I 16:05:04.070 NotebookApp] Saving file at /Untitled.ipynb
^C[I 16:05:18.396 NotebookApp] interrupted
Serving notebooks from local directory: ~
0 active kernels
Jupyter Notebook 6.3.0 is running at:
http://localhost:8888/?token=e5f60b72b0219930db87cfda37664107b266da3fe505bc17
 or http://127.0.0.1:8888/?token=e5f60b72b0219930db87cfda37664107b266da3fe505bc17

这似乎是一个 appnope 特定问题,尝试通过仅安装 appnope 并从 python shell.

导入它来减少

也许尝试从 pip 安装 appnope,因为 python 3.6 开始变老了,并且可能不支持更新的 macOS 版本上的 conda。

正如第一个答案所说,问题似乎源于 python 3.6、conda 和 macOS 11.5!我遵循了这个 post,它对我有用。

"通过设置在 IPython 内核中禁用 appnope:

# ~/.ipython/profile_default/ipython_kernel_config.py
c.Kernel._darwin_app_nap = False