【问题标题】:Jupyter Notebook: Kernel Error on the RightJupyter Notebook:右侧的内核错误
【发布时间】:2020-08-25 21:14:39
【问题描述】:

我刚刚安装了 Anaconda 并使用 jupyter notebook 命令通过命令行运行 Jupyter Notebook。但是,我面临一个问题。在右上角,我看到 内核错误 当我点击内核错误时,我看到这些行:

Traceback (most recent call last):
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
    result = await result
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\handlers.py", line 72, in post
    type=mtype))
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
    kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
    yielded = self.gen.throw(*exc_info)  # type: ignore
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
    self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
    value = future.result()
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
    yielded = next(result)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
    super(MappingKernelManager, self).start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 158, in start_kernel
    km.start_kernel(**kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 301, in start_kernel
    kernel_cmd, kw = self.pre_start_kernel(**kw)
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 248, in pre_start_kernel
    self.write_connection_file()
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 474, in write_connection_file
    kernel_name=self.kernel_name
  File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
    with secure_write(fname) as f:
  File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 424, in secure_write
    win32_restrict_file_to_user(fname)
  File "C:\Users\Shawn\AppData\Roaming\Python\Python37\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
    import win32api
ImportError: DLL load failed: %1 is not a valid Win32 application.

我无法在 Jupyter Notebook 上运行任何 Python 代码,因为我继续收到该错误。

我已经在 Stack Overflow 上经历了几个小时的无数线程。但我无法解决问题。 请帮我解决问题。我正在用 Python 做一门关于数据科学的课程。如果不解决此问题,我将无法继续前进。

更新 1: 我访问过这个Github thread 并尝试使用以下命令:

conda install -c conda-forge pywin32
conda install -c anaconda jupyter_client
conda install -c conda-forge jupyter_core
pip install --upgrade pywin32==224

但是,问题并未解决。相反,我收到了一个新错误,

ImportError: DLL load failed: The specified procedure could not be found.

这真是令人沮丧!

【问题讨论】:

    标签: jupyter-notebook kernel


    【解决方案1】:

    试试这个方法,我修好了我的 jupyter。
    同样的错误site-packages\tornado

    1. 命令
        jupyter kernelspec list
    
    1. 从显示的结果
         Available kernels:  
          python3    D:\Programs\Anaconda3\share\jupyter\kernels\python3
    
    1. 打开文件夹,编辑kernel.json
    {
        "argv": [
            "D:\\Programs\\Anaconda3\\python.exe",  //change to your correct path
            "-m",
            "ipykernel_launcher",
            "-f",
            "{connection_file}"
        ],
        "display_name": "Python 3",
        "language": "python"
    }
    
    1. 重启jupyter,就OK了。

    【讨论】:

      【解决方案2】:

      您是否尝试从终端打开 anaconda 导航器,然后创建一个环境并在该环境中安装 jupyter 笔记本,然后从导航器打开 jupyter 笔记本

      【讨论】:

      • 我尝试从 Anaconda Navigator 打开 Jupyter Notebook。但它没有用。但是,我设法找到了解决方案。
      【解决方案3】:

      好的。我已经设法解决了这个问题。我必须编写这些命令:

      conda install -c conda-forge pywin32
      conda install -c anaconda jupyter_client
      conda install -c conda-forge jupyter_core
      pip install --upgrade pywin32==224
      

      然后我得到一个错误。

      import win32api pywin32
      ImportError: DLL load failed: The specified procedure could not be found.
      

      我通过编写从github thread 得到的这个命令来解决这个问题:

      conda install pywin32
      

      现在,问题已经完全解决了!

      【讨论】:

        猜你喜欢
        • 2022-12-31
        • 1970-01-01
        • 2020-07-17
        • 1970-01-01
        • 2019-03-08
        • 2015-10-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多