当前位置: 代码迷 >> 综合 >> Jupyter Notebook运行代码无反应 解决方法
  详细解决方案

Jupyter Notebook运行代码无反应 解决方法

热度:46   发布时间:2023-10-15 19:45:59.0

在学习人脸识别知识的过程中需要用到Anaconda 、Jupyter Notebook.

我在启动Jupyter Notebook后,新建代码运行无反应。

从页面上也观察不出来是什么问题,后来在Anaconda Pormpt中启动Jupyter Notebook,我一开始还以为是自动启动的,傻傻的等它自动运行。。。结果是在浏览器中操作,命令行中才会跑模块的运行情况。要在浏览器中shift+enter执行代码片段,后台包这个错误。


(tensorflow) C:\Users\admin>jupyter notebook
[I 15:55:33.979 NotebookApp] The port 8888 is already in use, trying another port.
[I 15:55:34.011 NotebookApp] The port 8889 is already in use, trying another port.
[I 15:55:34.130 NotebookApp] Serving notebooks from local directory: C:\Users\admin
[I 15:55:34.131 NotebookApp] The Jupyter Notebook is running at:
[I 15:55:34.137 NotebookApp] http://localhost:8890/?token=7d8aff641154f969e61dec8ebd511d98849f08829e440fe0
[I 15:55:34.139 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 15:55:34.220 NotebookApp]To access the notebook, open this file in a browser:file:///C:/Users/admin/AppData/Roaming/jupyter/runtime/nbserver-24428-open.htmlOr copy and paste one of these URLs:http://localhost:8890/?token=7d8aff641154f969e61dec8ebd511d98849f08829e440fe0
Traceback (most recent call last):File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tornado\ioloop.py", line 888, in starthandler_func(fd_obj, events)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapperreturn fn(*args, **kwargs)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 450, in _handle_eventsself._handle_recv()File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 480, in _handle_recvself._run_callback(callback, msg)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\zmq\eventloop\zmqstream.py", line 432, in _run_callbackcallback(*args, **kwargs)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\tornado\stack_context.py", line 277, in null_wrapperreturn fn(*args, **kwargs)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 283, in dispatcherreturn self.dispatch_shell(stream, msg)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 233, in dispatch_shellself.pre_handler_hook()File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\site-packages\ipykernel\kernelbase.py", line 248, in pre_handler_hookself.saved_sigint_handler = signal(SIGINT, default_int_handler)File "C:\Users\admin\Anaconda3\envs\tensorflow\lib\signal.py", line 47, in signalhandler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread
[IPKernelApp] WARNING | Parent appears to have exited, shutting down.

然后参考https://blog.csdn.net/loovelj/article/details/82184223#commentBox  解决。

(tensorflow) C:\Users\admin>pip install "pyzmq==17.0.0" "ipykernel==4.8.2"
Collecting pyzmq==17.0.0Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pyzmq/Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/pyzmq/Downloading https://files.pythonhosted.org/packages/27/0b/a275f30738a014dc25443d2f45156ca739991df581fdaa40aa19df6c4f86/pyzmq-17.0.0-cp36-cp36m-win_amd64.whl (944kB)100% |████████████████████████████████| 952kB 49kB/s
Collecting ipykernel==4.8.2Downloading https://files.pythonhosted.org/packages/ab/3f/cd624c835aa3336a9110d0a99e15070f343b881b7d651ab1375ef226a3ac/ipykernel-4.8.2-py3-none-any.whl (108kB)100% |████████████████████████████████| 112kB 58kB/s
Requirement already satisfied: ipython>=4.0.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (6.1.0)
Requirement already satisfied: tornado>=4.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (4.5.2)
Requirement already satisfied: traitlets>=4.1.0 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (4.3.2)
Requirement already satisfied: jupyter-client in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from ipykernel==4.8.2) (5.2.4)
Requirement already satisfied: jupyter-core in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from jupyter-client->ipykernel==4.8.2) (4.4.0)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from jupyter-client->ipykernel==4.8.2) (2.6.1)
Requirement already satisfied: six>=1.5 in c:\users\admin\anaconda3\envs\tensorflow\lib\site-packages (from python-dateutil>=2.1->jupyter-client->ipykernel==4.8.2) (1.10.0)
Installing collected packages: pyzmq, ipykernelFound existing installation: pyzmq 17.1.2Uninstalling pyzmq-17.1.2:Successfully uninstalled pyzmq-17.1.2Found existing installation: ipykernel 4.6.1
Cannot uninstall 'ipykernel'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

安装时报错,ipykernel不能卸载,我也尝试过重新装,一直报这个错误。索性没管它,直接再浏览器中重新运行就可以正常运行了。

这是修复后的运行效果。

Jupyter Notebook运行代码无反应 解决方法

  相关解决方案