首页 > 解决方案 > 无法从 Visual Studio Code 打开 Jupyter 笔记本

问题描述

我正在尝试从 VSCode 打开 Jupyter Notebook。我尝试从命令面板打开。我收到以下错误

ModuleNotFoundError: No module named 'win32_extentions'

我已经安装了pywin32,但是当我尝试使用时出现以下错误

import win32api
from win32_extentions.win32api import *
ModuleNotFoundError: No module named 'win32_extentions'

当我尝试从终端直接打开浏览器时,出现内核错误。以下是日志文件

 To access the notebook, open this file in a browser:
        file:///C:/Users/sista/AppData/Roaming/jupyter/runtime/nbserver-25512-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=2df2d0e6a7282f6c007e60764040b5e761e7269c00ab0477
     or http://127.0.0.1:8888/?token=2df2d0e6a7282f6c007e60764040b5e761e7269c00ab0477
[I 16:11:28.617 NotebookApp] Creating new notebook in /
[E 16:11:28.776 NotebookApp] Uncaught exception POST /api/sessions?1589379088655 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions?1589379088655', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\web.py", line 1703, in _execute
        result = await result
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
        type=mtype))
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\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\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 742, in run
        yielded = self.gen.throw(*exc_info)  # type: ignore
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\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\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 735, in run
        value = future.result()
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\tornado\gen.py", line 209, in wrapper
        yielded = next(result)
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
        super(MappingKernelManager, self).start_kernel(**kwargs)
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\multikernelmanager.py", line 158, in start_kernel
        km.start_kernel(**kwargs)
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\manager.py", line 301, in start_kernel
        kernel_cmd, kw = self.pre_start_kernel(**kw)
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\manager.py", line 248, in pre_start_kernel
        self.write_connection_file()
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\connect.py", line 474, in write_connection_file
        kernel_name=self.kernel_name
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_client\connect.py", line 138, in write_connection_file
        with secure_write(fname) as f:
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\contextlib.py", line 81, in __enter__
        return next(self.gen)
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_core\paths.py", line 435, in secure_write
        win32_restrict_file_to_user(fname)
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
        import win32api
      File "C:\Users\sista\AppData\Local\Programs\Python\Python36\lib\site-packages\win32api.py", line 1, in <module>
        from win32_extentions.win32api import *
    ModuleNotFoundError: No module named 'win32_extentions'

标签: pythonvisual-studio-codejupyter-notebookjupyter

解决方案


推荐阅读