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
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.
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
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.
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