I am just starting to write my first Python scripts and everything was fine, until yesterday when I tried to run a Python script in cmd. Usually, I type: cd Desktop, and than file.py. It always worked, but suddenly when I type file.py, it opens up the script in Notepad++ and it doesn't run the program in cmd. I hope that someone can help..
2 Answers
cd Desktop, and than file.py
Try
cd Desktop
then
python file.py
Notice the keyword 'python' before file.py
Guess in your windows env, .py file already being assign to open with notepad++
Right click any .py files, click properties, change the open with to your python executable, eg. C:\python27\python.exe
OR
Explicitly specify to run it with python in cmd
cd Desktop
python file.py
PATH
environment variable and be sure that the path topython.exe
is present.python file.py
, well in case python.exe is in system pathfile association
. Something happened that caused .py files to be associated with Notepad.exe.