I am running windows 7. I have the default program for .py files set to the python.exe. If I double click a .py file it will launch correctly with python.

But in the windows explorer the icon next to .py files shows like it would if they were .txt (a sheet of paper with a folded corner)

Somewhere along the way the default program got set to notepad which is when the icon changed to this, but it has since been changed back to python and is working correctly with the python exe. But the icon didn't switch back when this change occurred.

Is there anything I can do to force it to switch to the standard .py icon rather than the txt one?

| |

According to THIS page, there are multiple ways of changing file extension icons, although I think "OPTION ONE" will be the easiest.

In your circumstances, this is what I think you need to do.

  1. Download FileTypesMan from HERE, and execute it.
  2. Scroll down until you find four Python extensions (.py, .pyc, .pyo , and .pyw).
  3. Double click on each of them individually, and replace the Default Icon field with the file path to the correct Python icon.
    1. For .py and .pyw the default file path to the icon should be something like C:\Python27\DLLs\py.ico (for Python 2.7) or C:\Python33\DLLs\py.ico (for Python 3.3).
    2. For .pyc and .pyo the default file path to the icon should be something like C:\Python27\DLLs\pyc.ico (for Python 2.7) or C:\Python33\DLLs\pyc.ico (for Python 3.3).
  4. Close FileTypesMan.

If you didn't use the default installation directory when installing Python, or used a different version, make sure you replace the C:\Python27 or C:\Python33 in the above file paths with the file path to your Python installation.

After completing all above steps, all your Python icons should have their correct icons. If for some reason they still don't, make sure you try rebooting your computer or double check the file path to the icons.

| |
  • Here's an FYI to anyone using this technique to open .py files with Sublime Text or whatever else (besides Python). I couldn't find a .ico file anywhere, but I was able to use this tool to extract the icon file from sublime_text.exe. Link: rw-designer.com/batch-icon-extractor – MarredCheese Apr 10 '17 at 21:22

This is mostly likely an icon caching issue. Windows 7 and Vista have been known to fail to update the icon cache when something changes, thus some old icons persist even across reboots.

The solution is usually to clear the icon cache. Try one of the solutions given there.

| |

I also had this issue. Here is what I did.

  1. Right click on a python program.
  2. Select properties.
  3. You will find "opens with" option in the general tab.
  4. Click change and select "python.exe".

Now, you will have your python icons back for all .py type of files.

| |

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.