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. Commented Nov 11, 2016 at 19:28
  • you could always do python file.py, well in case python.exe is in system path 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. 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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.