Jupyter Notebook 启动器使用指南

Jupyter Notebook 启动器是一个简单的批处理文件,旨在简化在桌面双击即可启动 Jupyter Notebook 的过程。它减去了手动打开命令提示符、导航到目标目录和启动 Jupyter Notebook 的繁琐步骤。

主要功能:

  • 一键启动:只需双击桌面上的 open_jupyter.bat 文件,即可快速启动 Jupyter Notebook。
  • 自动创建目录:如果指定的保存目录不存在,批处理文件会自动创建该目录。
  • 可自定义路径:用户可以根据需要更改 Jupyter Notebook 的保存目录。

第一部分:创建批处理文件

  1. 打开记事本

    • 在Windows系统中,点击“开始”菜单,搜索并选择“记事本”。
  2. 复制并粘贴代码

    • 将你提供的批处理代码复制到记事本中。
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      @echo off
      echo Jupyter notebook opening...
      timeout /t 1 /nobreak >nul
      echo Made by Bernie
      echo Your files will be saved in "D:\add\your\path"
      set "folderPath=D:\add\your\path"
      if not exist "%folderPath%" (
      mkdir "%folderPath%"
      )

      powershell -Command "Set-Location '%folderPath%'; jupyter notebook"
  3. 保存文件

    • 点击记事本的“文件”菜单,选择“另存为”。

    • 在“另存为”对话框中,将文件类型设置为“所有文件”,文件名命名为open_jupyter.bat(确保文件扩展名为.bat)。

    • 选择桌面作为保存位置,然后点击“保存”。

  4. 使用方法

第二部分:更改文件路径

如果你希望将Jupyter Notebook的文件保存到其他目录,请按照以下步骤操作:

  1. 编辑批处理文件

    • 右键点击桌面上的open_jupyter.bat文件,选择“打开方式” -> “记事本”。
  2. 修改路径

    • 找到以下代码行:
      1
      set "folderPath=D:\add\your\path"
    • 将其更改为你的目标路径。例如,如果你希望将文件保存在C:\Users\YourName\Documents\JupyterProjects,则修改为:
      1
      set "folderPath=C:\Users\YourName\Documents\JupyterProjects"
  3. 保存并关闭

    • 点击记事本的“文件”菜单,选择“保存”。
    • 关闭记事本。

第三部分:结束Jupyter Notebook和批处理文件

要结束Jupyter Notebook和批处理文件,请按照以下步骤操作:

  1. 快速结束Jupyter Notebook
    • 打开到正在显示类似以下内容的任务管理器
      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
         [I 2024-11-07 08:32:16.961 ServerApp] Extension package aext_assistant took 1.0463s to import
      [I 2024-11-07 08:32:17.023 ServerApp] ****************** ENVIRONMENT Environment.PRODUCTION ******************
      [I 2024-11-07 08:32:17.038 ServerApp] ****************** ENVIRONMENT Environment.PRODUCTION ******************
      [I 2024-11-07 08:32:17.433 ServerApp] Extension package jupyter_lsp took 0.3741s to import
      [W 2024-11-07 08:32:17.433 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-11-07 08:32:17.780 ServerApp] Extension package jupyter_server_terminals took 0.3336s to import
      [W 2024-11-07 08:32:22.698 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-11-07 08:32:35.162 ServerApp] Extension package panel.io.jupyter_server_extension took 12.4562s to import
      [I 2024-11-07 08:32:35.175 ServerApp] aext_assistant | extension was successfully linked.
      [I 2024-11-07 08:32:35.194 ServerApp] aext_core | extension was successfully linked.
      [I 2024-11-07 08:32:35.194 ServerApp] aext_panels | extension was successfully linked.
      [I 2024-11-07 08:32:35.194 ServerApp] aext_share_notebook | extension was successfully linked.
      [I 2024-11-07 08:32:35.194 ServerApp] jupyter_lsp | extension was successfully linked.
      [I 2024-11-07 08:32:35.247 ServerApp] jupyter_server_terminals | extension was successfully linked.
      [I 2024-11-07 08:32:35.299 ServerApp] jupyterlab | extension was successfully linked.
      [I 2024-11-07 08:32:35.374 ServerApp] notebook | extension was successfully linked.
      [I 2024-11-07 08:32:36.949 ServerApp] notebook_shim | extension was successfully linked.
      [I 2024-11-07 08:32:36.949 ServerApp] panel.io.jupyter_server_extension | extension was successfully linked.
      [I 2024-11-07 08:32:37.264 ServerApp] notebook_shim | extension was successfully loaded.
      [I 2024-11-07 08:32:37.266 ServerApp] Registered aext_assistant server extension
      [I 2024-11-07 08:32:37.266 ServerApp] aext_assistant | extension was successfully loaded.
      [I 2024-11-07 08:32:37.266 ServerApp] Registered aext_core server extension
      [I 2024-11-07 08:32:37.266 ServerApp] aext_core | extension was successfully loaded.
      [I 2024-11-07 08:32:37.277 ServerApp] Registered aext_panels server extension
      [I 2024-11-07 08:32:37.277 ServerApp] aext_panels | extension was successfully loaded.
      [I 2024-11-07 08:32:37.280 ServerApp] Registered aext_share_notebook_server server extension
      [I 2024-11-07 08:32:37.280 ServerApp] aext_share_notebook | extension was successfully loaded.
      [I 2024-11-07 08:32:37.296 ServerApp] jupyter_lsp | extension was successfully loaded.
      [I 2024-11-07 08:32:37.296 ServerApp] jupyter_server_terminals | extension was successfully loaded.
      [I 2024-11-07 08:32:37.364 LabApp] JupyterLab extension loaded from D:\bernie\ANACONDA\Lib\site-packages\jupyterlab
      [I 2024-11-07 08:32:37.364 LabApp] JupyterLab application directory is D:\bernie\ANACONDA\share\jupyter\lab
      [I 2024-11-07 08:32:37.364 LabApp] Extension Manager is 'pypi'.
      [I 2024-11-07 08:32:37.832 ServerApp] jupyterlab | extension was successfully loaded.
      [I 2024-11-07 08:32:37.863 ServerApp] notebook | extension was successfully loaded.
      [I 2024-11-07 08:32:37.879 ServerApp] panel.io.jupyter_server_extension | extension was successfully loaded.
      [I 2024-11-07 08:32:37.879 ServerApp] Serving notebooks from local directory: D:\programmes\jupyternotbook
      [I 2024-11-07 08:32:37.879 ServerApp] Jupyter Server 2.14.1 is running at:
      [I 2024-11-07 08:32:37.879 ServerApp] http://localhost:8888/tree?token=c3af23be44c9e2ab1c1df77a33433a88768c87e285b730a8
      [I 2024-11-07 08:32:37.879 ServerApp] http://127.0.0.1:8888/tree?token=c3af23be44c9e2ab1c1df77a33433a88768c87e285b730a8
      [I 2024-11-07 08:32:37.879 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
      [C 2024-11-07 08:32:38.305 ServerApp]

      To access the server, open this file in a browser:
      file:///C:/Users/berni/AppData/Roaming/jupyter/runtime/jpserver-13360-open.html
      Or copy and paste one of these URLs:
      http://localhost:8888/tree?token=c3af23be44c9e2ab1c1df77a33433a88768c87e285b730a8
      http://127.0.0.1:8888/tree?token=c3af23be44c9e2ab1c1df77a33433a88768c87e285b730a8
      [W 2024-11-07 08:32:38.575 ServerApp] Could not determine npm prefix: [WinError 2] 系统找不到指定的文件。
      [I 2024-11-07 08:32:40.102 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
      0.01s - Debugger warning: It seems that frozen modules are being used, which may
      0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
      0.00s - to python to disable frozen modules.
      0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
      [W 2024-11-07 08:32:55.081 ServerApp] wrote error: 'Forbidden'
      Traceback (most recent call last):
      File "D:\bernie\ANACONDA\Lib\site-packages\tornado\web.py", line 1790, in _execute
      result = await result
      ^^^^^^^^^^^^
      File "D:\bernie\ANACONDA\Lib\site-packages\aext_assistant_server\handlers.py", line 117, in get
      raise HTTPError(403, reason="missing nucleus_token")
      tornado.web.HTTPError: HTTP 403: missing nucleus_token
      [W 2024-11-07 08:32:55.226 ServerApp] 403 GET /aext_assistant_server/nucleus_token?1730939570778 (869ba06468444d0bb7c6d5923176142d@::1) 2372.50ms referer=http://localhost:8888/tree
      [W 2024-11-07 08:36:19.905 ServerApp] wrote error: 'Forbidden'
      Traceback (most recent call last):
      File "D:\bernie\ANACONDA\Lib\site-packages\tornado\web.py", line 1790, in _execute
      result = await result
      ^^^^^^^^^^^^
      File "D:\bernie\ANACONDA\Lib\site-packages\aext_assistant_server\handlers.py", line 117, in get
      raise HTTPError(403, reason="missing nucleus_token")
      tornado.web.HTTPError: HTTP 403: missing nucleus_token
      [W 2024-11-07 08:36:19.973 ServerApp] 403 GET /aext_assistant_server/nucleus_token?1730939779877 (869ba06468444d0bb7c6d5923176142d@::1) 100.08ms referer=http://localhost:8888/notebooks/Untitled.ipynb
      [I 2024-11-07 08:36:24.301 ServerApp] Kernel started: 291f2f0b-ddbc-491e-a777-be9fe844237f
      0.00s - Debugger warning: It seems that frozen modules are being used, which may
      0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
      0.00s - to python to disable frozen modules.
      0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
      [I 2024-11-07 08:36:27.752 ServerApp] Connecting to kernel 291f2f0b-ddbc-491e-a777-be9fe844237f.
      [I 2024-11-07 08:36:27.862 ServerApp] Connecting to kernel 291f2f0b-ddbc-491e-a777-be9fe844237f.
      [I 2024-11-07 08:36:28.068 ServerApp] Connecting to kernel 291f2f0b-ddbc-491e-a777-be9fe844237f.
      [W 2024-11-07 08:36:28.417 ServerApp] Got events for closed stream <zmq.eventloop.zmqstream.ZMQStream object at 0x0000016335ACCAD0>
      -然后

狂按Ctrl + c

  1. 正常结束Jupyter Notebook

    • 打开任务管理器(按Ctrl + Shift + Esc)。
    • 在“进程”选项卡中,找到名为jupyter-notebook.exe的进程。
    • 右键点击该进程并选择“结束任务”。
  2. 正常结束批处理文件

    • 再次打开任务管理器。
    • 在“进程”选项卡中,找到名为cmd.execonhost.exe的进程。
    • 右键点击该进程并选择“结束任务”。

通过以上步骤,你可以轻松地创建、修改路径和结束Jupyter Notebook及批处理文件。

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2023-2025 John Doe
  • Visitors: | Views:

请我喝杯茶吧~

支付宝
微信