How to config automatic sync Jupyter notebook .ipynb and .py files in VSCode e.g. by using Jupytext

Viewed 2146

I have written some Jupyter notebooks using original Jupyter notebook web interface. All notebooks are synced nicely in this way.

But now, I would like to edit my notebooks in the VSCode. But I cannot configure syncing notebook file with its python script.

I tried this using jupytext:

  • created file jupytext in the folder ~/.config
  • put the next code into this file:
# Always pair ipynb notebooks to py:percent files
default_jupytext_formats = "ipynb,py:percent"

But no effect!

(Update) Can this be achieved, as a first solution, using VSCode Tasks (I am not used tasks yet)?

May be it possible to run the task with jupytext command if the notebook file is opened/saved/modified?

1 Answers

Currently, VSCode does not support such a function. The Jupyter function in VSCode is provided by a Python extension, which supports us to convert between .ipynb files and .py files in VSCode.

.ipynb files to .py files : Export as python script.

.py files to .ipynb files : Right click, "Export Current Python File as Jupyter Notebook"

I have submitted the requirement you described, and we look forward to the realization of this feature. Giuhub link: How to synchronize the jupyter file and python file of VSCode.

Related