0

If I run the python script file from IDLE or Windows command prompt, I am able to view the error message.

Script file:

print(3/0)
input()

Error:

Traceback (most recent call last):
  File "...\TEST.py", line 1, in <module>
    print(3/0)
ZeroDivisionError: division by zero

But if I run the file by double clicking on it, the window just closes and I do not know what the error is. How can I see it?

I am running Python 3.4.

2 Answers 2

0

If you just double-click the file, once you hit an error, it terminates the program, thus closing the console window. To see the errors, you should run it from the command prompt.

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

Comments

0

This is how its supposed to work. When you "doubleclick" the .py file windows sees an executable file and invokes a cmd-shell and runs your python executable within (even though its only a text file, its considered as an executable - thats how you have set it in your system - this can be changed, say to make a doubleclick simply open the file in a text editor of your choice, like Notepad or Notepad++ or Python's default IDLE editor). Since division by 0 is an error, the cmd-shell is killed as soon as the error is seen in the .py file - your .py file is treated as an executable, much like how an .exe application crash doesn't wait for you before its killed.

If you do not want lose the window and wish to see the error, then you already seem to know what to do - run it by invoking python from a cmd-shell manually, or better still, use the built-in IDLE editor (Press F5 to run your script from an IDLE editor)

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.