By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,172 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,172 IT Pros & Developers. It's quick & easy.

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

P: n/a
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-Pro..._Goes_There%3F

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.

Nov 19 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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

Nov 19 '06 #2

P: n/a
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-Pro..._Goes_There%3F

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?
Nov 19 '06 #3

P: n/a
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?

Nov 19 '06 #4

P: n/a
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.

Nov 20 '06 #5

P: n/a
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...

Nov 20 '06 #6

P: n/a
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.

Nov 21 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.