IDLE subprocess startup error
Asked Answered
A

6

5

I have the code below in a file called code.py. I am using IDLE to edit the file. When I click Run>Run Module I get the error:

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

I am using Windows 7 Ultimate 64bit, but I have the 32bit version of Python 2.7 installed.

I have looked for a solution on this site as well as others but all of them seem to recommend deleting something called tkinter.py (I have no idea what this is) or to turn off my firewalls (I have none enabled aside from Microsoft Security Essentials which isn't a firewall.)

#Globals
#-------------------

x_pad = 476
y_pad = 444

import ImageGrab
import os
import time
import win32api, win32con

def screenGrab():
    box = (x_pad+1,y_pad+1,x_pad+641,y_pad+480)
    im = ImageGrab.grab(box)
    im.save(os.getcwd() + '\\full_snap__' + str(int(time.time())) +
'.png', 'PNG')

def main():
    pass

if __name__ == '__main__':
    main()

def leftClick():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(.1)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
    print 'Click.'          #completely optional. But nice for debugging purposes.

def leftDown():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
    time.sleep(.1)
    print 'left Down'

def leftUp():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
    time.sleep(.1)
    print 'left release'

def mousePos(cord):
    win32api.SetCursorPos((x_pad + cord[0], y_pad + cord[1])

def get_cords():
    x,y = win32api.GetCursorPos()
    x = x - x_pad
    y = y - y_pad
    print x,y
Alkyne answered 20/6, 2014 at 11:30 Comment(8)
Did IDLE once worked (with other python files) or is it the first time you use it (on that computer) ?Mensal
This error only comes up if I try to click run > Run module, If I double click the python file the code runs as intended.Alkyne
The question was about IDLE. Have you runned other python module via IDLE Run/Run module ? If not, you could try to de-install and re-install full Python as IDLE is part of core Python distribution.Mensal
Sorry, this is the first time I've had any Python or IDLE on my computer.Alkyne
Then I think that Python is badly installed and should be de-installed and re-installed.Mensal
Do not delete tkinter.py as that will disable Idle and all other tkinter appications. How are you starting Idle? What happens if you start it from the Start Menu icon?Edmon
@TerryJanReedy I'm having the same problem. Exacly as OP described, and when I start IDLE from the start menu, again I get the same error. The only way I can use IDLE is from the context menu, to edit a python document. I can't run the module and I can't open the IDE from start. I'm operating on a fresh install of python too, and I don't save my work to the python folder. The problem occurs on a government computer, so it may be the firewall, but why does IDLE need to go through the firewall? Is there no way to avoid this?Miche
@Miche Be default, IDLE executes user code in a separate process. Currently, the two processes communicate through a socket. Since sockets are mostly used to talk to processes on other machines (anywhere in the world), some machines monitor socket usage and they sometimes do not differentiate between within-machine and between-machine. If you have firewall, you might be able to configure is to not block internal communication. Or start IDLE on command line with -n option to run IDLE and user code in one process. This mostly works except when writing tkinter programs.Edmon
S
5

The thing is "python.exe" is being obstructed by "tkinter.py") that you created(i.e., you have written a program with Tk() and named it as tkinter.py and saved that in the root folder of python). And that's it just make sure that you don't save any program file directly in the root folder of python.

Sauers answered 9/5, 2015 at 12:3 Comment(0)
L
2

Another fix!!! Hopefully this will help someone.

I had the same problem and noticed something quite interesting. I had accidentally named a file (inside the desktop folder I was working in) "tkinter" (it will cause the same problem if you rename a file by any reserved keyword, I assume). Everytime I ran or attempted to run this file, it created a pycache folder, and the error you mention above came up. Deleting the erroneously named python file solved the problem.

So - look for ANY files (in the folder you are working with or indeed the root folder) that are named after any reserved words. Delete them. Hopefully it'll work!

Lishalishe answered 22/9, 2017 at 10:58 Comment(0)
C
1

I had the same problem. what i did that solved it, was to move every .py file that i had created in "C:\Python33" folder, to a sub-folder that i named "Examples". seems like one of my files was the cause of this problem.

Cognomen answered 27/10, 2014 at 21:55 Comment(0)
A
0

I also had the following problem. My file was named code.py, and was working fine untill I installed Canopy, and numpy.

I tried reinstalling python, but what solved the problem for me was simply renaming the file. I called my file myCode.py, everything started working fine. Strange problem...

Anfractuosity answered 26/4, 2015 at 15:45 Comment(0)
L
0

I made a python file and named it "socket.py" so then python IDLE showing an error on startup that 'startup failure' so the problem is that if we are using python reserved keywords or module names as our python file name that it conflicts with built-in modules. the solution is: go to path C:\Users\sony\AppData\Local\Programs\Python\Python38 where your python files are saved and just renamed that file. then start IDLE.

Laggard answered 26/3, 2021 at 18:37 Comment(0)
L
-1

Happily using IDLE continously under python36 and windows10, it has suddenly given this error on all the programs I'm working on, with no new files created.
I terminated IDLE and tried to restart it with idle.bat but that no longer works. Happily I have been able to restart it successfully with Lib\idlelib\idle.pyw. All my recent programs are there and they can again be run without problems. No need to reinstall python.

Lonne answered 2/7, 2020 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.