5
votes

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
6
Did IDLE once worked (with other python files) or is it the first time you use it (on that computer) ? - Serge Ballesta
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. - All Day
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. - Serge Ballesta
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? - Terry Jan Reedy
@Musixauce3000 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. - Terry Jan Reedy

6 Answers

5
votes

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.

2
votes

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!

1
votes

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.

0
votes

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...

0
votes

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.

-1
votes

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.