当我尝试在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中的问题相同,但是我可以通过配置&#34; run&#34;来绕过这个问题。行动到&#34;在新的专用控制台中执行&#34;。
答案 0 :(得分:3)
我的问题通过卸载anaconda解决,之后我下载并安装了最新的anaconda版本。
我认为通过阻止某些安装和/或配置设置,我的防病毒导致了旧Anaconda版本的初始安装问题。我的结论是基于以下事实:来自卡巴斯基的大量警告信息不断弹出,询问是否允许或阻止应用程序打开和运行的路径。
选择&#34;允许&#34;每次按钮都会让Jupyter正常工作。
答案 1 :(得分:0)
当使用Dockerfile中的CMD启动ipython / jupyter时,这仍在Docker环境中发生。如果从作为Docker入口点的sh脚本触发了start命令,那么问题就消失了。
Shell脚本很简单:
atomic_thread_fence()
答案 2 :(得分:0)
问题解决了。
应该归咎于防火墙。
只需更改另一个端口并要求管理员为我工作。
答案 3 :(得分:0)
我在Windows 10上也遇到了这个问题。为了解决这个问题,我启动了SageMath Shell,然后在Shell终端中,执行以下命令:
jupyter笔记本-无浏览器--ip = 0.0.0.0 --port = 8888
这将触发Windows防火墙提示,要求确认python 2.7.15的网络许可。我同时允许私有网络和公共网络的许可,但问题不再存在。
答案 4 :(得分:0)
pip install --upgrade pywin32==225
这为我解决了问题。