我可以从创建的 GUI 递归运行 Jupyter Notebook 吗?

can I run Jupyter Notebook recursively from the GUI created?

提问人:user22758952 提问时间:11/15/2023 更新时间:11/15/2023 访问量:9

问:

我试图通过单击生成的 GUI 中的按钮再次调用 Jupyter Notebook,但我收到此错误:

                      Error: [WinError 206] Název nebo přípona souboru je příliš dlouhá

(这意味着,当翻译成英文时是长路径名) 我把它缩短了,但没有帮助。 我使用的代码如下:

def execute_jupyter_script():
    try:
        # Convert the Jupyter notebook to a Python script
        notebook_path = 'C:/Users/Documents/U2.ipynb'  # Update with your Jupyter script path
        print(f"Reading notebook from path: {notebook_path}")
        with open(notebook_path, 'r', encoding='utf-8') as notebook_file:
            notebook_content = nbformat.read(notebook_file, as_version=4)
        
        python_exporter = PythonExporter()
        python_script, _ = python_exporter.from_notebook_node(notebook_content)
        
        # Execute the Python script
        result = subprocess.run(['python', '-c', python_script], stdout=subprocess.PIPE, universal_newlines=True)
        
        # Display the result in the output_text_area
        output_text_area.delete('1.0', tk.END)  # Clear previous content
        output_text_area.insert(tk.END, result.stdout)
    except Exception as e:
        print(f"Error: {e}")
        output_text_area.delete('1.0', tk.END)
        output_text_area.insert(tk.END, f"Error: {e}")
用户界面 递归 Jupyter-Notebook 运行时错误

评论


答: 暂无答案