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 if 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. Therefore, I believe something might be going on with the Python installation process. However, it also seems to me like this should be something that I could fix in Firefox's settings somewhere.

I've tried a bunch of stuff suggested on Mozilla's pages, including deleting the handlers.json file in my Profile folder, running a full Refresh, and creating a new profile. None of these got me back to the old behavior. General Googling has not helped; most of the results are out of date, and/or advise installation of a Firefox extension (no longer checked for security holes by Mozilla).

Any ideas? Thanks in advance.

P.S. I've got a similar question posted on support.mozilla.org and discuss.python.org, and will update if I get any answers from either of those.

P.P.S. [ETA] Running on Windows 10 Pro, Firefox v90.0.2.

  • Start > Choose a default app for each type of file > Scroll to .py and set firefox as the default app.
    – hunsbct
    Aug 3, 2021 at 17:18
  • Thanks for the suggestion, but .py (or PY) does not appear in the list of possible file types in settings. Also, note what I said above about trying to set Firefox as the default app to open a .py file, from the pop-up window: it doesn't work, it just keeps popping up the same window in another new tab.
    – bjkeefe
    Aug 3, 2021 at 17:24
  • Oh, sorry. You were talking about the Windows associations. No, I don't want to do that, because when I'm not in the browser, I want Python to run the .py files.
    – bjkeefe
    Aug 3, 2021 at 17:26
  • "I could click a link to a locally stored .py file" - It might be helpful to specify what link(s) you were actually clicking to get this behavior. Aug 3, 2021 at 17:41
  • Here is an example. I have files called "cheatsheet.html," which has got a dozen or so things that I had to write down to remember, back a few months ago. Typically, each of the items has a very quick bit of code, and then says something like this: <p>Example: <a href="file:///c:/bjk/Dropbox/notes/python/DCP/DCP0138/v02.py">DCP0138/v02.py</a></p> Note that the same problem (now) occurs if I open up a directory listing from within Firefox; e.g., "file:///c:/bjk/Dropbox/notes/python/cheatsheet/demos/" and then click a link to a .py file from there.
    – bjkeefe
    Aug 3, 2021 at 20:54

1 Answer 1


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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.