文章目录
报错背景
在使用 pycharm 付费版的过程中,发现一直无法启动 jupyter 服务器。
一直也不知道是为什么,直到在终端输入:
jupyter notebook
发现 jupyter 服务无法启动。
报错详细信息
下述是我运行
jupyter notebook
命令后的报错信息。
[I 2024-09-1415:51:53.496 ServerApp] Package notebook took 0.0000s to import[I 2024-09-1415:51:53.499 ServerApp] Package jupyter_lsp took 0.0030s to import[W 2024-09-1415:51:53.499 ServerApp] A `_jupyter_server_extension_points` function was not found in jupyter_lsp. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.[I 2024-09-1415:51:53.501 ServerApp] Package jupyter_server_terminals took 0.0013s to import[I 2024-09-1415:51:53.501 ServerApp] Package jupyterlab took 0.0000s to import
Fail to get yarn configuration. internal/modules/cjs/loader.js:638
throw err;^
Error: Cannot find module 'worker_threads'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /home/jie/anaconda3/lib/python3.11/site-packages/jupyterlab/staging/yarn.js:423:2576
at Object.<anonymous>(/home/jie/anaconda3/lib/python3.11/site-packages/jupyterlab/staging/yarn.js:743:8770)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)[I 2024-09-1415:51:53.635 ServerApp] Package notebook_shim took 0.0000s to import[W 2024-09-1415:51:53.635 ServerApp] A `_jupyter_server_extension_points` function was not found in notebook_shim. Instead, a `_jupyter_server_extension_paths` function was found and will be used for now. This function name will be deprecated in future releases of Jupyter Server.[I 2024-09-1415:51:53.880 ServerApp] Package panel.io.jupyter_server_extension took 0.2448s to import[I 2024-09-1415:51:53.880 ServerApp] jupyter_lsp | extension was successfully linked.[I 2024-09-1415:51:53.881 ServerApp] jupyter_server_terminals | extension was successfully linked.[I 2024-09-1415:51:53.882 ServerApp] jupyterlab | extension was successfully linked.[I 2024-09-1415:51:53.884 ServerApp] notebook | extension was successfully linked.[I 2024-09-1415:51:53.968 ServerApp] notebook_shim | extension was successfully linked.[I 2024-09-1415:51:53.968 ServerApp] panel.io.jupyter_server_extension | extension was successfully linked.[I 2024-09-1415:51:53.973 ServerApp] notebook_shim | extension was successfully loaded.[I 2024-09-1415:51:53.973 ServerApp] jupyter_lsp | extension was successfully loaded.[I 2024-09-1415:51:53.974 ServerApp] jupyter_server_terminals | extension was successfully loaded.[I 2024-09-1415:51:53.974 LabApp] JupyterLab extension loaded from/home/jie/anaconda3/lib/python3.11/site-packages/jupyterlab
[I 2024-09-1415:51:53.974 LabApp] JupyterLab application directory is/home/jie/anaconda3/share/jupyter/lab
[I 2024-09-1415:51:53.974 LabApp] Extension Manager is'pypi'.[I 2024-09-1415:51:53.975 ServerApp] jupyterlab | extension was successfully loaded.[I 2024-09-1415:51:53.976 ServerApp] notebook | extension was successfully loaded.[I 2024-09-1415:51:53.976 ServerApp] panel.io.jupyter_server_extension | extension was successfully loaded.[I 2024-09-1415:51:53.976 ServerApp] The port 8888is already in use, trying another port.
Traceback (most recent call last):
File "/home/jie/anaconda3/bin/jupyter-notebook", line 11,in<module>
sys.exit(main())^^^^^^
File "/home/jie/anaconda3/lib/python3.11/site-packages/jupyter_server/extension/application.py", line 618,in launch_instance
serverapp = cls.initialize_server(argv=args)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jie/anaconda3/lib/python3.11/site-packages/jupyter_server/extension/application.py", line 588,in initialize_server
serverapp.initialize(
File "/home/jie/anaconda3/lib/python3.11/site-packages/traitlets/config/application.py", line 113,in inner
return method(app,*args,**kwargs)^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jie/anaconda3/lib/python3.11/site-packages/jupyter_server/serverapp.py", line 2609,in initialize
self.init_httpserver()
File "/home/jie/anaconda3/lib/python3.11/site-packages/jupyter_server/serverapp.py", line 2432,in init_httpserver
self._find_http_port()
File "/home/jie/anaconda3/lib/python3.11/site-packages/jupyter_server/serverapp.py", line 2479,in _find_http_port
sockets = bind_sockets(port, self.ip)^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/jie/anaconda3/lib/python3.11/site-packages/tornado/netutil.py", line 162,in bind_sockets
sock.bind(sockaddr)
OSError:[Errno 99] Cannot assign requested address
解决方案
通过指定
--ip
后,发现程序已可成功运行。
jupyter notebook --ip=127.0.0.1
pycharm 设置
在pycharm jupyter 的设置中,设置:
notebook --no-browser --ip=127.0.0.1
然后, pycharm 就可以运行 jupyter .ipynb 文件。
本文转载自: https://blog.csdn.net/sjxgghg/article/details/142260436
版权归原作者 jieshenai 所有, 如有侵权,请联系我们删除。
版权归原作者 jieshenai 所有, 如有侵权,请联系我们删除。