jupytext icon indicating copy to clipboard operation
jupytext copied to clipboard

Automatically add shebang

Open txoof opened this issue 9 months ago • 5 comments

Is there a way to add the shebang to projects that start from within Jupyter? I can't find a way other than running:

!jupytext Untitled.ipynb --update-metadata '{"jupytext":{"executable":"/usr/bin/python"}}' --to py from within the notebook to do this.

This works, but is rather convoluted and requires some non-intuitive commands; this seems rather contrary to the ease of the rest of jupytext. The method above also causes the Reload/Cancel/Overwrite dialogue to pop up.

Related comment from @mwouts in https://github.com/mwouts/jupytext/issues/914#issuecomment-1032934480_

txoof avatar Oct 29 '23 14:10 txoof

Hi @txoof , well I don't think there is any other programmatic way to do this, but if you prefer you could directly edit the notebook metadata, like in this screenshot: image

mwouts avatar Nov 03 '23 23:11 mwouts

@mwouts

Thanks for the suggestion. That definitely works. It just feels hacky for such an otherwise comprehensive tool that does everything else almost magically.

I guess I'll migrate this to a feature request.

txoof avatar Nov 12 '23 13:11 txoof

Thanks 😊

I will think about this.

Maybe we could let users configure a default shebang or, more generally, a default metadata through the Jupytex configuration file.

These weeks, we are finishing Jupytext 1.16, which will improve the user experience in JLab 4, I will come back to this afterwards.

mwouts avatar Nov 12 '23 14:11 mwouts

@mwouts Thanks! Jupytext has revolutionized my workflow. I really love this tool!

txoof avatar Nov 15 '23 16:11 txoof

Glad you like it! Thank you for your kind works.

mwouts avatar Nov 16 '23 21:11 mwouts