【问题标题】:How to download a .py file from Jupyter lab notebook?如何从 Jupyter 实验室笔记本下载 .py 文件?
【发布时间】:2019-07-05 22:06:33
【问题描述】:

在 jupyter notebook 中,有一个规定可以将 notebook 下载为 .py 文件。在 jupyter 实验室中,有一个名为 export as 的选项,它不包含下载 .py 文件的选项。是否有任何解决方法,而不是复制笔记本中的脚本并将其粘贴到 python 文件中。

【问题讨论】:

    标签: python jupyter-notebook ipython jupyter jupyter-lab


    【解决方案1】:

    来自 jupyter 文档:(https://jupyterlab.readthedocs.io/en/stable/user/export.html) JupyterLab 允许您将 jupyter 笔记本文件 (.ipynb) 导出为其他文件格式,例如:

    Asciidoc .asciidoc
    
    HTML .html
    
    Latex .tex
    
    Markdown .md
    
    PDF .pdf
    
    ReStructured Text .rst
    
    Executable Script .py
    
    Reveal.js Slides .html
    

    要访问这些选项,请在笔记本打开时浏览“文件”菜单:

    【讨论】:

      【解决方案2】:

      在 Jupyter 实验室中,转到文件菜单。选择“Export Notebook as”,然后选择“Export Notebook to Executable Script”选项。

      对于 Jupyter notebook,在 Jupyter notebook 的文件菜单中有“下载为”选项。您可以从可用选项列表中选择 Python (.py)。

      【讨论】:

      • 这个问题是给 jupyter 实验室的。
      • @TarunKumarYellapu 我已经更新了在 Jupyter 实验室中导出的答案。
      • 这将导出.py 文件,删除所有结构(例如单元格)。有没有办法下载为.ipynb
      • "Export Notebook to Executable Script" 在我的 mac 中保存了一个 .py.html 文件。没有python可执行文件
      • 您应该能够通过删除 .html 扩展名来运行该文件。这是一个 Safari 的事情。
      猜你喜欢
      • 1970-01-01
      • 2019-03-06
      • 1970-01-01
      • 2017-06-29
      • 2021-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多