Just installed Python 3.9.6. Firefox will now no longer open local .py files as plain text

Hi, everyone. Sorry if this is an inappropriate place to post this question.

Up until a few days ago, I could click a link to a locally stored .py file and Firefox would display it as a plain text file. This is what I want; e.g., it’s a way for me to organize notes, view examples I’ve created in the past, and like that.

Now when I click such a link, Firefox pops up a window asking me if I want to “Open with …” or “Save file”.

I installed Python 3.9.6 a few days ago, so I wondered it that was a coincidence. I don’t think it is, because I just went to another machine, where clicking a link to a .py file worked as desired, updated the Python on that machine, and now I’m seeing the same (unwanted) behavior.

I do have a question posted about this in the Mozilla support forum, but I thought I ought to mention this here, too. And ask if there is anything that’s new in the Python installation procedure that would cause this. And if so, is it something I could fix by re-installing Python and doing something different during the installation?

Thanks in advance for any suggestions.

P.S. Both machines are running Win 10 Pro, and both are running Firefox v90.0.2.

Not that many people seem to care, but just in case, for someone in the future …

When I didn’t find a solution to the above, I decided the least painful way to deal with the problem was to go into Settings > Applications in Firefox, and associate PY files with Emacs. So, now when I click a link to one of my local .py files, an Emacs window pops up, with that file in it.

Due to a typo a couple of days ago, I discovered another workaround: in the URL for the file, just append a dot, and then the proper file will open in the browser, as a plain text file, which is all I ever wanted. (Well, not all.) That is, this line in an HTML file will cause the file to open in a pop-up Emacs window …

<a href="file:///c:/some-dir/example.py">example.py</a>

… but this will open the same file, right in the browser (note the dot after the .py extension):

<a href="file:///c:/some-dir/example.py">example.py.</a>

The installation seems to have changed how Firefox associates MIME types based on the file extension. Did you previously have another version of Python installed? If so, which version(s)? Did you install 3.9.6 using the python.org distribution, the app from the store, or something else?

There’s an “Open in Browser” extension for Firefox. As the name suggests, it extends the open dialog with the capability to open a file directly in the browser. I think it defaults to using the MIME type based on the file extension, which won’t help in this case, but there’s a dropdown list of ways to open the file, including opening as text.

Thanks for your detailed response.

Yes, I did. I forget exactly which one, but it would have been either 3.8.x or an earlier version of 3.9. The former is/was much more likely.

The first; i.e., via download of the installer from Download Python | Python.org

That looks pretty promising! I will give it a shot when I have a little more time and a clearer head, and I will try to remember to report back.

Here is a direct link for anyone else who is curious.

Thanks again, @eryksun.

[ETA] P.S. I’m a little concerned about the permissions this extension requires, which seem excessive. (Which is why I did not install it immediately.) I looked through the comments, on the extension’s home page, and came across a link to the developer’s response to these concerns. That response seems entirely reasonable, but … well, three things. First, you have to trust the developer. Second, if you do, you also have to trust that this developer will not have a change of mind. Third, you have to trust that no one else will take control of this extension (which happens kind of a lot).

Anyway, as I said, I will give it a shot, and try to remember to report back.

@eryksun Installed it. Could not get it to work. Thanks for the suggestion, nonetheless.