Python Forum
Dissaperaing window - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Dissaperaing window (/thread-29779.html)



Dissaperaing window - MrEmEs - Sep-19-2020

Hi,
I started learning Python today, so please don't hate me Naughty

I wrote a simple script:
print("Hello_world")

input("\n\nPress enter to close the program.")
and saved it as Helloworld.py

According to Michael Dawson book,
after double-clicking on that file, it should pop up a window.
My problem is that after double-clicking that file cmd window opens, but disappear after a second.
Any guesses what might be the case? Pray


RE: Dissaperaing window - deanhystad - Sep-19-2020

We all hate you very much.

The input should hold the window open waiting for you to press the enter key, and it does when I run this program using Python 3.8 under windows. What are you using?


RE: Dissaperaing window - buran - Sep-19-2020

Most probably there is error in your program which makes the screen show and close immediately
Note that the snippet you show here is OK, probably there is error in your code in the file or you are using python2 to run it (you should be using python3)
that said it's always better to open cmd/terminal and run the script from there, instead of double-click on the file


RE: Dissaperaing window - jefsummers - Sep-19-2020

I would recommend you use an IDE. That way you see messages, errors, get highlighting, lots of benefits.
IDLE is the IDE that comes with Python. Not great, but it will work
VSCode is becoming the most popular, though there are others. Installing and using it via Anaconda gives you lots of capability, including switching to Spyder if you prefer.
Notebook style programming is also a great option when learning. Get to run snippets and see results, fix and move to the next step. Highly recommended. Jupyter Lab (again installed with the Anaconda default install) works well, but you can also use Colab (colab.research.google.com) without even installing anything on your computer. Fast and works well.

Bottom line is that you need some method to see the error message and double clicking won't give that to you.