Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dissaperaing window
#1
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
Reply
#2
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?
Reply
#3
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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,744 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,167 Jun-13-2022, 08:59 AM
Last Post: Shena76

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020