Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening plain Python in Jupyter's default text edit, not as 'light script'? #744

Closed
dumbledad opened this issue Feb 15, 2021 · 3 comments
Closed

Comments

@dumbledad
Copy link

Is it possible to configure Jupytext so that plain Python files do not open in 'light script' view but in Jupyter's default editor (for text files)?

@mwouts
Copy link
Owner

mwouts commented Feb 15, 2021

Hi @dumbledad , yes this is possible. In your Jupyter configuration file, you could set

c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"
c.ContentsManager.notebook_extensions = "ipynb,md"

and then Jupyter will only open .ipynb and .md files as notebooks by default. However, you won't be able to open .py files as notebooks at all. Paired notebooks will continue to work.

Note that you might also be interested in the "edit trick" documented at #183.

@dumbledad
Copy link
Author

dumbledad commented Feb 16, 2021

Thanks @mwouts. Just to be clear a 'percent Script' Python file that was paired to a ipynb file on a colleague's machine and pushed to a remote Git repository will open on my machine in Jupyter as a notebook, i.e. the paired ipynb file will be recreated?

@mwouts
Copy link
Owner

mwouts commented Feb 16, 2021

You're welcome.

Well, if py is not in the notebook extensions you won't be able to open .py files as notebooks - still, what you can do is to recreate the .ipynb paired file with jupytext --sync, and then open that file.

Also, from your question I think you are using Jupyter Notebook. If switching to Jupyter Lab is an option, maybe you could consider that. In Jupyter Lab the user experience is a bit closer to what you are looking for: by default text files are edited with the "editor" window, and you get the notebook view only if you right click and select "open with notebook".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants