Converting to (not from) ipython Notebook format

后端 未结 10 971
刺人心
刺人心 2020-11-29 17:10

IPython Notebook comes with nbconvert, which can export notebooks to other formats. But how do I convert text in the opposite direction? I ask because I already ha

相关标签:
10条回答
  • 2020-11-29 17:42

    Took the liberty of taking and modifying the code of P.Toccateli and alexis so that it will also work with pycharm and spyder like cell markers and released it on github.

    0 讨论(0)
  • 2020-11-29 17:42

    I wrote an extension for vscode that might help. It converts the python files to ipython notebooks. It's in early stages so if any error occurs, feel free to submit an issue.

    Jupyter Notebook Converter

    0 讨论(0)
  • 2020-11-29 17:44

    very old question, i know. but there is jupytext (also available on pypi) that can convert from ipynb to several formats and back.

    when jupytext is installed you can use

    $ jupytext --to notebook test.py
    

    in order to generate test.ipynb.

    jupytext has a lot more interesting features that can come in handy when working with notebooks.


    here is a more recent question on that topic.

    0 讨论(0)
  • 2020-11-29 17:44

    Hope I'm not too late.

    I just published a Python package on PyPI called p2j. This package creates a Jupyter notebook .ipynb from a Python source code .py.

    pip install p2j
    p2j script.py
    

    Example of a Jupyter notebook generated from a .py file:

    PyPI: https://pypi.org/project/p2j/

    GitHub: https://github.com/remykarem/python2jupyter

    0 讨论(0)
提交回复
热议问题