Convert .py files runnable in VSCode/Python or Atom/Hydrogen to jupyter .ipynb notebooks and vice versa
Atom/Hydrogen or VSCode/Python allows creating a python files split into cells with
# %% separators with the ability to run cells via backend Jupyter session and interactively show results back.
ipynb-py-convert python module converts files: .ipynb to .py and .py to .ipynb.
ipynb-py-convert is a fork of the vscode-ipynb-py-converter.
conda install -c defaults -c conda-forge ipynb-py-convert
pip install ipynb-py-convert
- If encoding problems on Windows try using
set PYTHONUTF8=1in Windows console and use
ipynb-py-convertfor UTF-8 files only. If using Git-Bash on Windows setting:
export LANG=C.UTF-8 export PYTHONIOENCODING=utf-8 export PYTHONUTF8=1
should be enough. Also try setting default Bash settings to UTF-8: [Options] - [Text] - [Locale / Character set] - [C / UTF-8]. It might affect all Bash runs so there would be no need to setting encoding every time.
ipynb-py-convert examples/plot.py examples/plot.ipynb
ipynb-py-convert examples/plot.ipynb examples/plot.py
Markdown cells are converted to python multiline strings
'''. Code cells are left as is.
# %% is used by vscode as the cell marker on which 'Run Cell' action is available.
Jupyter ipynb notebook
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.