【问题标题】:How do I convert IPython v3 notebooks to Jupyter v4?如何将 IPython v3 笔记本转换为 Jupyter v4?
【发布时间】:2015-05-18 18:19:23
【问题描述】:

有没有办法将我所有的旧 v3 笔记本批量转换为 v4(用于 Jupyter)?

我的本​​地文件系统上有大量旧的 v3 IPython 笔记本。将 IPython 升级到 Jupyter 后,每当我打开 v3 笔记本时都会收到一个烦人的提示,通知我文件转换为 v4。我对转换完全没问题,但弹出窗口有点烦人。我想通过提前转换我所有的 v3 笔记本来抢占它们。谢谢!

【问题讨论】:

    标签: jupyter-notebook jupyter


    【解决方案1】:

    有一个名为 nbconvert 的工具应该可以解决问题。

    ipython nbconvert --to=notebook testnotebook.ipynb
    

    请始终备份您的旧文件,因为转换回来是 根据discussion,并不总是那么干净

    这是 nbconvert 工具的完整帮助:

    python nbconvert -h
    This application is used to convert notebook files (*.ipynb) to various other
    formats.
    
    WARNING: THE COMMANDLINE INTERFACE MAY CHANGE IN FUTURE RELEASES.
    
    Options
    -------
    
    Arguments that take values are actually convenience aliases to full
    Configurables, whose aliases are listed on the help line. For more information
    on full configurables, see '--help-all'.
    
    --stdout
        Write notebook output to stdout instead of files.
    --quiet
        set log level to logging.CRITICAL (minimize logging output)
    --debug
        set log level to logging.DEBUG (maximize logging output)
    --inplace
        Run nbconvert in place, overwriting the existing notebook (only
        relevant when converting to notebook format)
    --execute
        Execute the notebook prior to export.
    --init
        Initialize profile with default config files.  This is equivalent
        to running `ipython profile create <profile>` prior to startup.
    --to=<CaselessStrEnum> (NbConvertApp.export_format)
        Default: 'html'
        Choices: ['custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides']
        The export format to be used.
    --writer=<DottedObjectName> (NbConvertApp.writer_class)
        Default: 'FilesWriter'
        Writer class used to write the  results of the conversion
    --output=<Unicode> (NbConvertApp.output_base)
        Default: ''
        overwrite base name use for output files. can only be used when converting
        one notebook at a time.
    --profile-dir=<Unicode> (ProfileDir.location)
        Default: ''
        Set the profile location directly. This overrides the logic used by the
        `profile` option.
    --ipython-dir=<Unicode> (BaseIPythonApplication.ipython_dir)
        Default: ''
        The name of the IPython directory. This directory is used for logging
        configuration (through profiles), history storage, etc. The default is
        usually $HOME/.ipython. This option can also be specified through the
        environment variable IPYTHONDIR.
    --config=<Unicode> (BaseIPythonApplication.extra_config_file)
        Default: ''
        Path to an extra config file to load.
        If specified, load this config file in addition to any other IPython config.
    --template=<Unicode> (TemplateExporter.template_file)
        Default: 'default'
        Name of the template file to use
    --post=<DottedOrNone> (NbConvertApp.postprocessor_class)
        Default: ''
        PostProcessor class used to write the  results of the conversion
    --reveal-prefix=<Unicode> (RevealHelpPreprocessor.url_prefix)
        Default: 'reveal.js'
        The URL prefix for reveal.js. This can be a a relative URL for a local copy
        of reveal.js, or point to a CDN.
        For speaker notes to work, a local reveal.js prefix must be used.
    --profile=<Unicode> (BaseIPythonApplication.profile)
        Default: 'default'
        The IPython profile to use.
    --log-level=<Enum> (Application.log_level)
        Default: 30
        Choices: (0, 10, 20, 30, 40, 50, 'DEBUG', 'INFO', 'WARN', 'ERROR', 'CRITICAL')
        Set the log level by value or name.
    --nbformat=<Enum> (NotebookExporter.nbformat_version)
        Default: 4
        Choices: [1, 2, 3, 4]
        The nbformat version to write. Use this to downgrade notebooks.
    
    To see all available configurables, use `--help-all`
    
    Examples
    --------
    
        The simplest way to use nbconvert is
    
        > ipython nbconvert mynotebook.ipynb
    
        which will convert mynotebook.ipynb to the default format (probably HTML).
    
        You can specify the export format with `--to`.
        Options include ['custom', 'html', 'latex', 'markdown', 'notebook', 'pdf', 'python', 'rst', 'script', 'slides']
    
        > ipython nbconvert --to latex mynotebook.ipynb
    
        Both HTML and LaTeX support multiple output templates. LaTeX includes
        'base', 'article' and 'report'.  HTML includes 'basic' and 'full'. You
        can specify the flavor of the format used.
    
        > ipython nbconvert --to html --template basic mynotebook.ipynb
    
        You can also pipe the output to stdout, rather than a file
    
        > ipython nbconvert mynotebook.ipynb --stdout
    
        PDF is generated via latex
    
        > ipython nbconvert mynotebook.ipynb --to pdf
    
        You can get (and serve) a Reveal.js-powered slideshow
    
        > ipython nbconvert myslides.ipynb --to slides --post serve
    
        Multiple notebooks can be given at the command line in a couple of
        different ways:
    
        > ipython nbconvert notebook*.ipynb
        > ipython nbconvert notebook1.ipynb notebook2.ipynb
    
        or you can specify the notebooks list in a config file, containing::
    
            c.NbConvertApp.notebooks = ["my_notebook.ipynb"]
    
        > ipython nbconvert --config mycfg.py
    

    【讨论】:

    • 解决方案好运吗?
    • 这个版本的命令有效:jupyter nbconvert --inplace --to=notebook *.ipynb
    猜你喜欢
    • 2015-12-10
    • 2015-05-12
    • 1970-01-01
    • 1970-01-01
    • 2022-10-02
    • 2013-04-06
    • 2014-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多