jupyter报错 psutil 包版本冲突

报错如下

  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\comm\__init__.py", line 3, in <module>
    from .comm import Comm
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\comm\comm.py", line 14, in <module>
    from ipykernel.kernelbase import Kernel
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 35, in <module>
    import psutil
  File "D:\Program Files (x86)\anaconda\lib\site-packages\psutil\__init__.py", line 241, in <module>
    raise ImportError(msg)
ImportError: version conflict: 'D:\\Program Files (x86)\\anaconda\\lib\\site-packages\\psutil\\_psutil_windows.cp39-win_amd64.pyd' C extension module was built for another version of psutil (5.9.0 instead of 5.9.2); you may try to 'pip uninstall psutil', manually remove D:\Program Files (x86)\anaconda\lib\site-packages\psutil\_psutil_windows.cp39-win_amd64.pyd or clean the virtual env somehow, then reinstall
[I 15:25:39.886 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Traceback (most recent call last):
  File "D:\Program Files (x86)\anaconda\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\Program Files (x86)\anaconda\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\kernelapp.py", line 51, in <module>
    from .ipkernel import IPythonKernel
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\ipkernel.py", line 19, in <module>
    from .comm.comm import BaseComm
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\comm\__init__.py", line 3, in <module>
    from .comm import Comm
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\comm\comm.py", line 14, in <module>
    from ipykernel.kernelbase import Kernel
  File "D:\Program Files (x86)\anaconda\lib\site-packages\ipykernel\kernelbase.py", line 35, in <module>
    import psutil
  File "D:\Program Files (x86)\anaconda\lib\site-packages\psutil\__init__.py", line 241, in <module>
    raise ImportError(msg)
ImportError: version conflict: 'D:\\Program Files (x86)\\anaconda\\lib\\site-packages\\psutil\\_psutil_windows.cp39-win_amd64.pyd' C extension module was built for another version of psutil (5.9.0 instead of 5.9.2); you may try to 'pip uninstall psutil', manually remove D:\Program Files (x86)\anaconda\lib\site-packages\psutil\_psutil_windows.cp39-win_amd64.pyd or clean the virtual env somehow, then reinstall
[I 15:25:46.209 NotebookApp] Interrupted...
[I 15:25:46.212 NotebookApp] Shutting down 1 kernel
[I 15:25:46.215 NotebookApp] Kernel shutdown: bff6a4e9-c005-404c-a5fb-7a39daaadfdf
[I 15:25:46.222 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
  File "D:\Program Files (x86)\anaconda\lib\site-packages\jupyter_client\manager.py", line 85, in wrapper
    self._ready.set_result(None)

解决办法

这个错误消息指出 psutil 包的版本冲突。

1.卸载 psutil 包:运行以下命令从 Anaconda 环境中卸载 psutil 包:

pip uninstall psutil

2.清理环境:运行以下命令清理环境:

conda clean --all

3.重新安装 psutil 包:运行以下命令重新安装 psutil 包:

conda install psutil

完成这些步骤后,再次尝试启动笔记本服务器,问题是否已解决。

你可能感兴趣的:(Python学习私人笔记,jupyter,python,开发语言)