0

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..

3
  • You don't give us enough details, check the PATH environment variable and be sure that the path to python.exe is present.
    – Marcs
    Commented Nov 11, 2016 at 19:28
  • you could always do python file.py, well in case python.exe is in system path
    – 4c74356b41
    Commented Nov 11, 2016 at 20:50
  • This happens because of Windows file association. Something happened that caused .py files to be associated with Notepad.exe.
    – lit
    Commented Nov 12, 2016 at 21:50

2 Answers 2

1

cd Desktop, and than file.py

Try

cd Desktop

then

python file.py

Notice the keyword 'python' before file.py

0

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

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