Jupyter opens .py files as notebooks instead of the classic text editor

For some unknown reason Jupyter is opening the .py files as notebooks instead of the classic text editor. Does anybody knows why and how to fix this?

Thanks

This isn’t much to go on.
You haven’t specified versions or how you are initiating things, system this is running on, etc.? Please in the near future read Getting good answers to your questions and use it as a guide to posting here.

You can try some of the latest versions on a temporary remote machine to take this a way from a ‘on my computer’ situation. (Possibly. Since again, you didn’t specify where you are running this.)
You can at least compare what you are seeing with how these options perform:

For Jupyter Notebook, go here and click on the 'launch binder' badge you see there. When the session comes up, make a text file with the .py extension. Save it and then try to open it. It will open in the editor currently with Jupyter Notebook Version: 7.5.0b0.

For JupyterLab, go here and click on the 'launch binder' badge you see there. When the session comes up, make a new Python file using the launcher. Save it and then try to open it from the file browser panel on the left. It will open in the editor currently with JupyterLab Version 4.4.7.

Other ideas…
If you are opening a .py file directly from your operating system and it is opening as a .ipyb, that is controlled by settings you can adjust.
Also, do you maybe have an extension involved? Jupytext maybe? I believe that can give you different options for dealing with files.

Hi fomightez, here is all the versions Installed. I am using an older version of notebook 6.5 and would like to stay on this one. A similar setup has always worked so far but for some reason not anymore. I was wondering if there is a configuration somewhere that tell jupyter what application to run based on the file extension.
The link for the launch binder seems wrong.

Regarding how I use jupyter. I run jupyter server on a remote machine (like so jupyter-notebook –port xxxx) and forward it to my local machine via ssh (-L xxx:localhost:xxx). The .ipynb files are opened normally as notebook and the .py as well as notebook.

notebook 6.5.6
notebook_shim 0.2.4
ipython 8.36.0
ipython-genutils 0.2.0
jupyter 1.1.1
jupyter_client 7.4.9
jupyter-console 6.6.3
jupyter_core 5.7.2
jupyter-events 0.12.0
jupyter-lsp 2.2.5
jupyter_server 2.17.0
jupyter_server_fileid 0.9.3
jupyter-server-mathjax 0.2.6
jupyter_server_proxy 4.4.0
jupyter_server_terminals 0.5.3
jupyter_server_ydoc 0.6.1
jupyter-ydoc 0.2.5
jupyterlab 3.6.0
jupyterlab-nvdashboard 0.5.0
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.3
jupyterlab-topbar 0.6.1
jupyterlab_widgets 1.1.11

OS: 22.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux

It’s hard to say what changed given you are using older things. I’m guessing something you didn’t pin? Using NbClassic may give you the older version style and extensions you like while fixing the situation. Eventually you are going have to move from the older version you are using otherwise. You already have encountered an issue.

I fixed the first Launch Binder link in my original reply.