I was wondering if I was the only one who felt the urge to apply a tad of humor
and suppressed most of the thoughts about idol/IDLE worship and other puns so I
am glad to see Steve do just a little of the same.
It seems that despite how portable Python is touted to be, quite a few people
report problems in getting the basics working when installing. And if you can't
get started, that is obviously a barrier. My suggestion earlier was based on
the fact that IDLE is an add-on and they should first check if Python itself
works. Any text editor can be used that just produces plain text and scripts
can be run in other ways.
But I have a thought. An old an often effective method to solve a problem is to
search in the source code. Yes, you did not write IDLE.
I am still not clear on how IDLE aborts on startup but I recall that IDLE may
be written in Python with source code available. I went into python to see
where to look by seeing the path it would search.
>>> import sys
>>> print(sys.path)
I then followed a trail and what I found was idlelib with many components and
when I import that library in the IDLE main unit I see some of the results:
>>> import idlelib
>>> dir(idlelib)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
'__package__', '__path__', '__spec__', 'autocomplete', 'autocomplete_w',
'calltip_w', 'calltips', 'config', 'debugger', 'debugger_r', 'debugobj',
'debugobj_r', 'hyperparser', 'iomenu', 'macosx', 'multicall', 'pyparse', 'rpc',
'run', 'scrolledlist', 'stackviewer', 'testing', 'tree', 'windows',
'zoomheight']
I could potentially follow along, and for a while I did. I think that after a
few steps, on my machine, it hits pyshell in
C:\Users\avid2016\AppData\Local\Programs\Python\Python37-32\Lib\idlelib and
then runs code starting with:
#! /usr/bin/env python3
import sys
try:
from tkinter import *
except ImportError:
print("** IDLE can't import Tkinter.\n"
"Your Python may not be configured for Tk. **", file=sys.__stderr__)
raise SystemExit(1)
And it goes on and on. It imports all kinds of things and creates many classes
and if called directly, runs a big function called main. I searched for
"subprocess" and "IDLE" to see if the file had whatever error message you saw
and I think I found it in the definition of a function:
def display_no_subprocess_error(self):
tkMessageBox.showerror(
"Subprocess Startup Error",
"IDLE's subprocess didn't make connection. Either IDLE can't "
"start a subprocess or personal firewall software is blocking "
"the connection.",
parent=self.tkconsole.text)
Correction, the first argument of "self' was a hint and that is actually a
method in:
class ModifiedInterpreter(InteractiveInterpreter):
Now if that is the error message, you work backwards to see when it might have
been called/triggered.
Searching for a call to that method shows two places:
Here is one snippet:
self.spawn_subprocess()
#time.sleep(20) # test to simulate GUI not accepting connection
# Accept the connection from the Python execution server
self.rpcclt.listening_sock.settimeout(10)
try:
self.rpcclt.accept()
except socket.timeout:
self.display_no_subprocess_error()
return None
Here is the other:
self.spawn_subprocess()
try:
self.rpcclt.accept()
except socket.timeout:
self.display_no_subprocess_error()
return None
I am going to stop now and suggest it happens when IDLE creates a subprocess to
run in parallel and plays games with sockets and fails.
FWIW, the method called before is:
def spawn_subprocess(self):
if self.subprocess_arglist is None:
self.subprocess_arglist = self.build_subprocess_arglist()
self.rpcsubproc = subprocess.Popen(self.subprocess_arglist)
Presumably something goes wrong in there but I suspect the Popen failed.
Why would it fail? Well, it could be many things including whatever actual info
is in the arglist ...
That might take plenty of additional digging including suggestions about
something not being set right in the path or other registry components or some
rogue library component being imported rather than the intended one or so much
more. But, in theory, you can even take the source code and run it more
carefully and debug this. Not something for a novice.
Not sure if that helps but if I actually had to read all that code and do
serious debugging, it might take me days and I have a funeral and a party
(unrelated) to go to today alone
-Original Message-
From: Tutor On Behalf Of Steven
D'Aprano
Sent: Saturday, November 17, 2018 6:18 AM
To: tutor@python.org
Subject: Re: [Tutor] Regarding "IDLE Subprocess Didn't Make Connection" Error
On Thu, Nov 15, 2018 at 03:38:28PM -0800, Break fast wrote:
> "IDLE subprocess didn't make