【发布时间】:2017-06-17 19:05:25
【问题描述】:
当我尝试在 Jupyter Notebook 中运行我的代码时,没有任何反应。细胞没有反应。这是我尝试运行单元时发生(或者更确切地说,没有发生)的屏幕截图。
我已尝试单击“内核”选项卡下的“重新启动并运行所有”选项。它只给我一个内核已经死亡的警告消息:
如果我单击警告消息上的“立即尝试重新启动”按钮,消息会消失,但代码仍然不会运行。但是,如果我只是离开笔记本很长一段时间(我认为花了一个小时),代码最终会运行并且笔记本会正常运行。
我输入的问题是简单的单行,例如print (2 + 2),或import numpy as np,如第一个屏幕截图所示,但这些行没有被执行。
我在笔记本上运行 Python 3.5,它是使用 Anaconda Navigator 打开的。此外,我的操作系统是 Windows 10。
我已尝试卸载并重新安装 Anaconda(Python 3 和 Python 2 版本)并关闭我的防病毒软件,但似乎没有任何解决问题的方法。
有谁知道为什么会发生这种情况以及如何解决?任何帮助将不胜感激!
终端消息如下:
[I 12:43:00.890 NotebookApp] Serving notebooks from local directory: C:\Users\Essi
[I 12:43:00.891 NotebookApp] 0 active kernels
[I 12:43:00.891 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 12:43:00.891 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 12:43:26.635 NotebookApp] Kernel started: 7612964e-692c-430c-99ba-b0ed2190f12c
[W 12:43:36.822 NotebookApp] Timeout waiting for kernel_info reply from 7612964e-692c-430c-99ba-b0ed2190f12c
[I 12:43:55.421 NotebookApp] Kernel restarted: 7612964e-692c-430c-99ba-b0ed2190f12c
[I 12:44:15.437 NotebookApp] Kernel restarted: 7612964e-692c-430c-99ba-b0ed2190f12c
[W 12:44:25.425 NotebookApp] Timeout waiting for kernel_info_reply: 7612964e-692c-430c-99ba-b0ed2190f12c
[E 12:44:25.427 NotebookApp] Exception restarting kernel
Traceback (most recent call last):
File "C:\Users\Essi\Anaconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 88, in post
yield gen.maybe_future(km.restart_kernel(kernel_id))
File "C:\Users\Essi\Anaconda3\lib\site-packages\tornado\gen.py", line 1008, in run
value = future.result()
File "C:\Users\Essi\Anaconda3\lib\site-packages\tornado\concurrent.py", line 232, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
tornado.gen.TimeoutError: Timeout waiting for restart
[E 12:44:25.507 NotebookApp] {
"Referer": "http://localhost:8888/notebooks/Documents/Vac%20Work%20progs/123.ipynb",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Host": "localhost:8888",
"Content-Length": "0",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"X-Requested-With": "XMLHttpRequest",
"Accept-Language": "en-US,en;q=0.5",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0"
}
[E 12:44:25.508 NotebookApp] 500 POST /api/kernels/7612964e-692c-430c-99ba-b0ed2190f12c/restart (::1) 31148.06ms referer=http://localhost:8888/notebooks/Documents/Vac%20Work%20progs/123.ipynb
[I 12:44:26.615 NotebookApp] Kernel shutdown: 7612964e-692c-430c-99ba-b0ed2190f12c
[W 12:44:27.626 NotebookApp] Session not found: session_id='8d2aafbc-0bc6-47b8-9648-6c3650d07513'
[W 12:44:27.627 NotebookApp] 404 DELETE /api/sessions/8d2aafbc-0bc6-47b8-9648-6c3650d07513 (::1) 2.00ms referer=http://localhost:8888/notebooks/Documents/Vac%20Work%20progs/123.ipynb
[I 12:44:27.677 NotebookApp] Kernel started: e5487dea-ffa3-4498-9238-c70df3c58963
[W 12:44:37.717 NotebookApp] Timeout waiting for kernel_info reply from e5487dea-ffa3-4498-9238-c70df3c58963
[W 12:44:45.448 NotebookApp] Timeout waiting for kernel_info_reply: 7612964e-692c-430c-99ba-b0ed2190f12c
[E 12:44:45.448 NotebookApp] Exception restarting kernel
Traceback (most recent call last):
File "C:\Users\Essi\Anaconda3\lib\site-packages\notebook\services\kernels\handlers.py", line 88, in post
yield gen.maybe_future(km.restart_kernel(kernel_id))
File "C:\Users\Essi\Anaconda3\lib\site-packages\tornado\gen.py", line 1008, in run
value = future.result()
File "C:\Users\Essi\Anaconda3\lib\site-packages\tornado\concurrent.py", line 232, in result
raise_exc_info(self._exc_info)
File "<string>", line 3, in raise_exc_info
tornado.gen.TimeoutError: Timeout waiting for restart
[E 12:44:45.450 NotebookApp] {
"Referer": "http://localhost:8888/notebooks/Documents/Vac%20Work%20progs/123.ipynb",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Host": "localhost:8888",
"Content-Length": "0",
"Accept-Encoding": "gzip, deflate",
"Connection": "keep-alive",
"X-Requested-With": "XMLHttpRequest",
"Accept-Language": "en-US,en;q=0.5",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0"
}
[E 12:44:45.451 NotebookApp] 500 POST /api/kernels/7612964e-692c-430c-99ba-b0ed2190f12c/restart (::1) 31061.81ms referer=http://localhost:8888/notebooks/Documents/Vac%20Work%20progs/123.ipynb
[I 12:44:47.055 NotebookApp] Kernel shutdown: e5487dea-ffa3-4498-9238-c70df3c58963
[I 12:45:26.611 NotebookApp] Saving file at /Documents/Vac Work progs/123.ipynb
[W 12:51:54.702 NotebookApp] Session not found: session_id='3fef32b0-5580-4ea5-b61e-9fe5b3892368'
[W 12:51:54.703 NotebookApp] 404 DELETE /api/sessions/3fef32b0-5580-4ea5-b61e-9fe5b3892368 (::1) 1.02ms referer=http://localhost:8888/notebooks/Documents/Vac%20Work%20progs/123.ipynb
[I 12:51:54.784 NotebookApp] Kernel started: ceb9046d-94e3-467b-96a3-e8f49bcfbb87
[W 12:52:04.824 NotebookApp] Timeout waiting for kernel_info reply from ceb9046d-94e3-467b-96a3-e8f49bcfbb87
我进一步尝试的方法包括仅关闭防火墙、关闭浏览器中的阻止程序以及尝试在 Chrome 和 Edge 中运行 jupyter。我也试过pip install -U jsonschema,之后得到如下回复:
C:\Users\Essi>pip install -U jsonschema
Could not fetch URL https://pypi.python.org/simple/jsonschema/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645) - skipping
Requirement already up-to-date: jsonschema in c:\users\essi\anaconda3\lib\site-packages
上述操作均无济于事。 certificate verify failed 响应是否导致另一个问题?
我能够打开一个 Ipython 会话(我希望您指的是可以执行代码的黑屏)。但是,Spyder 中的 Ipython 控制台与 Jupyter 中的问题相同,但我可以通过将“运行”操作配置为“在新的专用控制台中执行”来绕过此问题。
【问题讨论】:
-
您从终端的哪个目录启动笔记本服务器?您是否在该目录中下载或安装或制作了自己的 python 包?尝试从空目录启动 jupyter notebook,看看问题是否仍然存在。
-
能否请您在终端中发布输出(在浏览器打开之前启动的黑色窗口)?
-
另一个想法 - 当你在没有笔记本的情况下打开 ipython 会话时它是否有效?
-
Github 和 SO 上有很多解决方案,但没有一个适合我,所以我现在开始赏金。
标签: python anaconda jupyter-notebook