Python IDLE subprocess error?
Asked Answered
H

8

10

IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection.

Don't think this has been asked-how come this comes up occasionally when running very simple programs-I then have to go to Task Manager & stop all Pythonw processes to get it to work again?

It seems to happen randomnly on different bits of code-here is the one I'm doing at the moment-

f = open('money.txt')
currentmoney = float(f.readline())
print(currentmoney, end='')
howmuch = (float(input('How much did you put in or take out?:')))
now = currentmoney + howmuch
print(now)
f.close()
f = open('money.txt', 'w')
f.write(str(now))
f.close()

Sometimes it works, sometimes it doesn't!

Husbandman answered 17/5, 2009 at 14:42 Comment(0)
E
1

In Python 3.0.1, I have gotten that error after I Ctrl-C to interrupt a previous run of a program in Idle's Python Shell and then try to run a script.

Also in 3.0.1: Let's say you have two Idle windows open: a script open for editing in one, and Idle's Python Shell window. I have found that if you close the shell window and then immediately try to run the script, it will give that error when it tries to re-open the shell - but not if you wait a bit in between to let Idle do whatever connection clean up it needs to do.

Worse bugs I have found (again, in v3.0.1- not sure if this would happen in the 2.x versions): I had a long script - getting up towards 9k lines - and once it got to a certain size, doing "save as" on it would crash Idle. I am not sure what the exact threshold was for size - but before that, I would also get some intermittent "save as" crashes that seemed to depend on what else I had going on - other Idle windows, how much output was in the shell window perhaps - stuff like that. It can crash and you will lose unsaved work.

Also - one thing I commonly do is have a scratch window open where I cut and paste bits of code in various stages of validity, write notes to myself, etc - so not a valid python script, but I sometimes save these so I can come back to them. I have one such file that will crash Idle every time I try to open it - and I lost unsaved work the first time. (FYI: Other editors including PythonWin 2.5.2 have no problem opening the file.)

Engrave answered 17/5, 2009 at 16:17 Comment(4)
Sounds pretty similar-I'll keep the ways to get around it in mind, thanks! Is there a way to file a bug report or similar?Husbandman
I have this problem, but it occurs even after a clean OS restart on the first attempt to start a python run. The only thing I do is to open the file in IDLE and hit F5. I'm running python 3.2.Pewit
@JamesWanchai and anyone else: One can open issues at bugs.python.org, but one must register and should search for a similar open issue. Posting to python-list, either directly or via the gmane.comp.python.general mirror at news.gmane.org may be better. Or email [email protected].Hyaloid
If opening a opening an ascii or utf-8 encoded text file today causes IDLE to close or crash, I'd like to know. Was your scratch file called .py, .txt, or ...?Hyaloid
L
5

I was getting the same error message. What was causing the problem for me was that I named one of my scripts 'string.py'. Every time I tried to run a script with 'string.py' in the same directory this happened.

Lather answered 10/3, 2012 at 10:37 Comment(0)
I
3

You can use idle -n to avoid such issues (albeit possibly getting some other limitations).

Immigration answered 18/5, 2009 at 5:6 Comment(5)
Would you care to elaborate on what this does? I tried to RTFM, but found no mention. docs.python.org/3.0/library/idle.html#command-line-usageAppreciable
Not sure why it's missing from the docs -- look at the sources, idlelib/PyShell.py in your Python install: -n sets use_subprocess to False, so idle runs the user's code in the same process as the shell and GUI instead of using a subprocess.Immigration
@Appreciable In the recent releases (2.7.11, 3.4.4, 3.5.1, Nov/Dec 2015), go to Help, IDLE Help and you will see the IDLE doc nicely formatted. Click TOC and then 3.3 Running without a subprocess. The formatting and TOC are new with these releases.Hyaloid
@TerryJanReedy: Interesting that (a) it doesn't appear under Command line usage, and (b) that it is deprecated since 3.4.Appreciable
Well it works. But the reason I want to use IDLE is because I want to be able to to use Run Module to open my code in a console environment where I can then work interactively with my code as I develop it. It seems running without a sub-process prevents this feature. Can you think of any other solution for me?Violante
F
2

I had this same problem in 2.7.3. I found that when I was learning how to use tkinter and I made a basic program to open a window, I named it Tkinter.py and put it in the same folder as the program I was trying to run with IDLE. It would always compile the program called Tkinter and make a second compiled file. When I tried to run my other program I would get the error message. I renamed my simple windows-opening program to something else and deleted the compiled file. I was able to run every program in that folder with IDLE no problem.

Floatage answered 16/7, 2012 at 18:26 Comment(0)
P
1

Can you be more specific by providing a short code sample?

IDLE has some threading issues. So the first thing to debug your problem would be to print some simple stuff in your subprocess. Thereby you will see whether it is a network or threading related issue.

Panhandle answered 17/5, 2009 at 15:19 Comment(0)
E
1

In Python 3.0.1, I have gotten that error after I Ctrl-C to interrupt a previous run of a program in Idle's Python Shell and then try to run a script.

Also in 3.0.1: Let's say you have two Idle windows open: a script open for editing in one, and Idle's Python Shell window. I have found that if you close the shell window and then immediately try to run the script, it will give that error when it tries to re-open the shell - but not if you wait a bit in between to let Idle do whatever connection clean up it needs to do.

Worse bugs I have found (again, in v3.0.1- not sure if this would happen in the 2.x versions): I had a long script - getting up towards 9k lines - and once it got to a certain size, doing "save as" on it would crash Idle. I am not sure what the exact threshold was for size - but before that, I would also get some intermittent "save as" crashes that seemed to depend on what else I had going on - other Idle windows, how much output was in the shell window perhaps - stuff like that. It can crash and you will lose unsaved work.

Also - one thing I commonly do is have a scratch window open where I cut and paste bits of code in various stages of validity, write notes to myself, etc - so not a valid python script, but I sometimes save these so I can come back to them. I have one such file that will crash Idle every time I try to open it - and I lost unsaved work the first time. (FYI: Other editors including PythonWin 2.5.2 have no problem opening the file.)

Engrave answered 17/5, 2009 at 16:17 Comment(4)
Sounds pretty similar-I'll keep the ways to get around it in mind, thanks! Is there a way to file a bug report or similar?Husbandman
I have this problem, but it occurs even after a clean OS restart on the first attempt to start a python run. The only thing I do is to open the file in IDLE and hit F5. I'm running python 3.2.Pewit
@JamesWanchai and anyone else: One can open issues at bugs.python.org, but one must register and should search for a similar open issue. Posting to python-list, either directly or via the gmane.comp.python.general mirror at news.gmane.org may be better. Or email [email protected].Hyaloid
If opening a opening an ascii or utf-8 encoded text file today causes IDLE to close or crash, I'd like to know. Was your scratch file called .py, .txt, or ...?Hyaloid
V
1

Simple. Just cut all files with .py extension, paste them in a place different from the os path, one of the files is causing such error. Run the IDLE again.

Vent answered 20/10, 2011 at 19:6 Comment(0)
F
0

If it look like truly random behavior than it could be a multi-cpu/core issue. You could try to set the interpreter affinity to a fixed cpu and see if this issue still comes up.

Google for something like: imagecfg process affinity For more information about that.

Formalize answered 21/5, 2009 at 10:34 Comment(0)
F
0

i had the same error. I did a modem reboot and to my surprise, it worked !

Fowling answered 18/6, 2014 at 16:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.