I'm learning python on x64 windows 7 machine. But after installing and uninstalling python 2.7 and 3.2 a few times too many (i just found out 3.x doesn't support some of the 3rd party libraries like PIL), i have lost .py file association(when i double click my python scripts, windows asks me to choose a program to open it with instead of making python interpret it). How can i fix the issue?
2 Answers
considering you've already set the path in environment variables:
open command prompt
:
cd
to the directory which contains lost.py
and then type:
python lost.py
and hit enter.
or using IDLE:
start IDLE --> press CTRL+O --> open your file --> press F5
-
why the downvote?– Ashwini ChaudharySep 23, 2012 at 18:42
-
4You got downvoted because you did not answer the question of "how do I fix my file associations" but instead answered "how do I run my python file".– GuvanteFeb 16, 2016 at 18:53
From an elevated command prompt:
C:\Windows\System32>assoc .py=PythonFile
.py=PythonFile
C:\Windows\System32>ftype PythonFile=py.exe "%1" %*
PythonFile=python.exe "%1" %*
Notice that the ""
are included in the ftype
output.
Alternatively, use FileTypesMan.
pythonw.exe
, and check the option that tells Windows to use it for all future.py
files as well.