python - Jupyter notebook 无法连接到内核(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 分钟,但没有成功并返回错误!
我得到的错误(我只是复制最后几行,因为 Stackoverflow 不允许我发布太多代码):
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
解决方案
正如第一个答案所说,问题似乎源于 python 3.6、conda 和 macOS 11.5!我关注了这篇文章,它对我有用。
“通过设置禁用 IPython 内核中的 appnope:
# ~/.ipython/profile_default/ipython_kernel_config.py
c.Kernel._darwin_app_nap = False
推荐阅读
- c# - 动画模式以在控制台中从左到右移动 vom
- swift - 使用 JSON 数据从 Swift 调用云函数
- karate - 空手道和黄瓜之间不兼容的黄瓜json报告
- python-3.x - 获取不同的列数据框
- python - 如何让python将几个总数相加并打印总数
- sql - 调整磁盘大小后 PostgreSQL 查询非常慢
- python - 如何在带有字符串的列表上使用for循环更改变量名
- php - 在 null 上调用成员函数 addMessage(),
- xamarin.forms - Xamarin Forms:如何编写将在后台连续运行的服务,直到从设备上卸载应用程序?
- elasticsearch - 带有嵌套 AND/OR 查询的 Elasticsearch