How do I stop Python IDLE (GUI) from immediately exiting when I enter it?

Discussion in 'Python' started by John (Z R) L, Nov 19, 2006.

  1. John (Z R) L

    John (Z R) L Guest

    Hi all, I am very new to programming, and I chose to study the Python
    language before C++. I am currently using the Wikibooks
    "Non-Programmer's Tutorial for Python", and am up to the section "Who
    goes there"?

    http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python/Who_Goes_There?

    But after clicking "run module" for
    "
    a = 1
    print a
    a = a + 1
    print a
    a = a * 2
    print a "

    The results "1, 2, 4" didn't appear on the GUI screen, in fact nothing
    did. And I clicked twice again, this time, it exited the Python GUI
    program. I tried to enter back in, but it would quickly display

    "1
    2
    4"

    before exiting immediately within half a second. How do I stop the this
    exiting from occurring.

    Another problem I have is firewall. On my old computer (Windows 98)
    when using Python GUI, it can't run modules because of some firewall.
    But I thought firewalls were for internet sites only?! How do I fix
    this??

    Thank you in advance, and I apologize for my ignorance.
    John (Z R) L, Nov 19, 2006
    #1
    1. Advertising

  2. John (Z R) L wrote:

    > But after clicking "run module"


    Being new is never problem, but do learn to provide concise, complete
    descriptions of exactly what happened and what you were doing at the
    time.

    Are you in IDLE? Or are you in PythonWin? OR did you make a script
    file and try to run it by double clicking on it?

    Sounds like you were creating a script file, then tried to run it?
    Search this list at Google Groups comp.lang.python for "keep DOS box
    open."

    http://tinyurl.com/wh7fy

    > Another problem I have is firewall. On my old computer (Windows 98)
    > when using Python GUI, it can't run modules because of some firewall.


    Please enter the exact error message you get. It's probably some
    officious Windows security glitch, but nobody can help you until you
    provide the messages you get.

    Windows 98? Linux would run twice as fast on any machine old enough to
    run Windows 98, and your Python would work better, too.

    Good luck,

    rd
    BartlebyScrivener, Nov 19, 2006
    #2
    1. Advertising

  3. John (Z R) L

    Hertha Steck Guest

    Am Sat, 18 Nov 2006 23:24:08 -0800 schrieb John (Z R) L:

    > Hi all, I am very new to programming, and I chose to study the Python
    > language before C++. I am currently using the Wikibooks
    > "Non-Programmer's Tutorial for Python", and am up to the section "Who
    > goes there"?
    >
    > http://en.wikibooks.org/wiki/Non-Programmer's_Tutorial_for_Python/Who_Goes_There?
    >
    > But after clicking "run module" for
    > "
    > a = 1
    > print a
    > a = a + 1
    > print a
    > a = a * 2
    > print a "
    >
    > The results "1, 2, 4" didn't appear on the GUI screen, in fact nothing
    > did. And I clicked twice again, this time, it exited the Python GUI
    > program. I tried to enter back in, but it would quickly display
    >
    > "1
    > 2
    > 4"
    >
    > before exiting immediately within half a second. How do I stop the this
    > exiting from occurring.
    >


    All of this using IDLE as your GUI (not PythonWin and not the python
    interpreter by itself), right?

    You did all this as explained at the start of the tutorial: open a "New
    window", type the code into this empty window, save it to a reasonable
    place and then click "Run / Run module". Right? (Silly question: there is
    no run menu in the interactive window. On the other hand, you never know.)

    What about the examples before this one, did you type, save and run them
    just like this one? And did they work as you expected?

    What version of Python and of IDLE do you use?

    If you have PythonWin (it's part of ActiveState Python, for example): what
    happens, if you run your script using that? What happens if you open a
    command window, go to the right directory and run your script from there?
    (Don't try to start it by double clicking in the explorer: it will run,
    but the window will close immediately afterwards, and you won't see
    anything.)

    > Another problem I have is firewall. On my old computer (Windows 98)
    > when using Python GUI, it can't run modules because of some firewall.
    > But I thought firewalls were for internet sites only?! How do I fix
    > this??
    >


    Do you mean this?

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface. This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

    This shouldn't keep any script from running. What exactly happens if you
    try?
    Hertha Steck, Nov 19, 2006
    #3
  4. John (Z R) L

    John (Z R) L Guest

    Thanks for the replies so far. I do exactly what that website says, and
    on the old computer (Windows 98), I click run module and nothing
    happens. No text gets displayed on my IDLE. It contained that firewall
    message at the top.

    Back on the new computer, I deleted all of my .py files and I could go
    back to the Python IDLE (GUI) again.

    But my problem is with that when I run this module:
    "a = 1
    print a
    a = a + 1
    print a
    a = a * 2
    print a" ,

    the "1
    2
    4"
    appears on the screen, but the program doesn't end. You don't get a new
    ">>>" like when you finish running all the other modules. So when I
    want to run other modules, it says:
    "The Python Shell Window is already executing a command; please wait
    until it is finished."

    Note that all of my modules don't need any "end" at the last line, nor
    do I need "raw_input" to end the program.

    How do I make it so this module ends without using the word "end"
    because it would exit the entire IDLE Shell?
    John (Z R) L, Nov 19, 2006
    #4
  5. John (Z R) L

    Hertha Steck Guest

    Am Sun, 19 Nov 2006 14:32:45 -0800 schrieb John (Z R) L:

    > Thanks for the replies so far. I do exactly what that website says, and
    > on the old computer (Windows 98), I click run module and nothing
    > happens. No text gets displayed on my IDLE. It contained that firewall
    > message at the top.
    >
    > Back on the new computer, I deleted all of my .py files and I could go
    > back to the Python IDLE (GUI) again.
    >


    First of all: did you try to run the script using PythonWin and did you
    run it in a command window? What happened? What error messages did you
    get, if any?

    The script itself doesn't contain any errors. And in my IDLE it behaves
    perfectly well.

    And please, if you answer, keep the text you are answering. This is no web
    forum where you can see several postings at once.
    Hertha Steck, Nov 20, 2006
    #5
  6. John (Z R) L

    John (Z R) L Guest

    > First of all: did you try to run the script using PythonWin and did you
    > run it in a command window? What happened? What error messages did you
    > get, if any?
    >
    > The script itself doesn't contain any errors. And in my IDLE it behaves
    > perfectly well.
    >
    > And please, if you answer, keep the text you are answering. This is no web
    > forum where you can see several postings at once.


    The script is running perfectly fine now for some strange reason?? But
    previously it wasn't.

    I always type my script in a new Window of the IDLE interface, and when
    I do "Run Module", the output appears in the main Python Shell (IDLE).

    When I tried to run the script, "1,2,4" would appear, but the new
    prompt (>>>) DOESN'T appear. So when I want to run other modules that I
    made, Python Shell will say something like "Can't run script, in the
    middle of another module process.".

    So I have to exit the Python Shell, and then it says "You are currently
    running a module, kill it?". I click "Yes", but when I reenter the
    program, "1,2,4" suddenly appear on the output, then the program
    immediately exits within half a second.

    I solve this by deleting the .py and .pyc file which it keeps on
    displaying, and the Python IDLE gets reset.

    I don't have to delete stuff anymore because the scripts are running
    fine now. But I'm worried that this error will happen again
    (randomly?!), and I'll be in for more inconvenience...
    John (Z R) L, Nov 20, 2006
    #6
  7. John (Z R) L

    Hertha Steck Guest

    Am Mon, 20 Nov 2006 12:11:32 -0800 schrieb John (Z R) L:

    >> First of all: did you try to run the script using PythonWin and did you
    >> run it in a command window? What happened? What error messages did you
    >> get, if any?
    >>
    >> The script itself doesn't contain any errors. And in my IDLE it behaves
    >> perfectly well.
    >>
    >> And please, if you answer, keep the text you are answering. This is no web
    >> forum where you can see several postings at once.

    >
    > The script is running perfectly fine now for some strange reason?? But
    > previously it wasn't.
    >
    > I always type my script in a new Window of the IDLE interface, and when
    > I do "Run Module", the output appears in the main Python Shell (IDLE).
    >
    > When I tried to run the script, "1,2,4" would appear, but the new
    > prompt (>>>) DOESN'T appear. So when I want to run other modules that I
    > made, Python Shell will say something like "Can't run script, in the
    > middle of another module process.".
    >
    > So I have to exit the Python Shell, and then it says "You are currently
    > running a module, kill it?". I click "Yes", but when I reenter the
    > program, "1,2,4" suddenly appear on the output, then the program
    > immediately exits within half a second.
    >


    All this looks like a script with an endless loop in it. But in the code
    you posted there is no loop at all.

    > I solve this by deleting the .py and .pyc file which it keeps on
    > displaying, and the Python IDLE gets reset.
    >


    Then I suppose you typed the script again from scratch? Possibly you had
    some error in it that didn't show in your posting. But I don't think that
    can be cleared up now.

    > I don't have to delete stuff anymore because the scripts are running
    > fine now. But I'm worried that this error will happen again
    > (randomly?!), and I'll be in for more inconvenience...


    If that happens: try your script in the command window. And if at all
    possible, look at it in a hex viewer to find not printable characters that
    might corrupt the file. And post again, but be sure to cut and paste your
    code.
    Hertha Steck, Nov 21, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Plunket
    Replies:
    6
    Views:
    814
    Peter Hansen
    Jul 15, 2003
  2. Alan Isaac

    stop script w/o exiting interpreter

    Alan Isaac, Jan 25, 2007, in forum: Python
    Replies:
    6
    Views:
    367
    Gabriel Genellina
    Jan 28, 2007
  3. W. eWatson
    Replies:
    0
    Views:
    217
    W. eWatson
    Feb 5, 2010
  4. Peter Juuls
    Replies:
    8
    Views:
    187
    Ian Wilson
    Feb 16, 2006
  5. HopfZ
    Replies:
    0
    Views:
    542
    HopfZ
    Aug 28, 2006
Loading...

Share This Page