Help! no matter how much i reainstall python it cant open a file with an .py file extention

hello i wanted to learn python to hopefully wirite 3d python scripts and i have this issue where windows cant read .py files i tried reinstalling didnt help but other extentions such as .pyw work fine i dont know why tf that happened does anybody know how to fix this issue? mb writing a shortcut to launch .py files yourself?


i can only imbed 1 screenshot so have an imgur link instead

i downloaded/installed python by using the winget install -i python.python3 and checked all the boxes
windows 10

Reinstalling software over and over again is superstition.

If it didn’t do what you expected the first time, reinstalling it over and over again won’t magically make it behave differently. That’s like saying “I can’t find my blue shirt in the wardrobe, no matter how many times I open and close the wardrobe door its still not there!”

What do you mean by this?

“windows cant read .py files”

Are you getting I/O errors or Windows fatal errors? Is the computer crashing?

“other extentions such as .pyw work fine”

What does “work fine” mean to you?

Explain what steps you are doing:

(1) How did you create the .pyw file?

(2) What did you do next? Double-click the file? Something else?

(3) What happened then?

Same for the .py file:

(1) How did you create the .py file?

(2) What did you do next? Double-click the file? Something else?

(3) What did you expect to happen?

(4) What actually happened?

Based on the screenshot, it seems the file association dialog isn’t giving you the option to associate .py files with the Python launcher, but the association is correct for other Python file types such as .pyw and .pyz.

Try it other ways. Open the properties dialog of a .py file, and click “change”. Also try the context menu’s “open with”->“choose another app”. Retry after logging off and logging back on again, which reinitializes the shell.

If none of this helps, you’ll have to try a more advanced approach that involves modifying the registry directly.

Add “.PY” to your PATHEXT environment variable.
On the commandline enter:
SET PATHEXT=.PY;%PATHEXT%
To do it permanently, type ‘environment’ in your windows search box, click on the icon labeled ‘Edit the system environment variables’; on the resultant System Properties dialog, at the bottom click the button for ‘Environment Variables’. In the lower window ‘System variables’ scroll down to PATHEXT and edit it to make sure .PY is in the list of file extensions.