我在名为 code.py
的文件中有以下代码。我正在使用 IDLE
来编辑文件。单击 Run>Run Module
时出现错误:
"IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess of personal firewall software is blocking the connection."
我使用的是 Windows 7 Ultimate 64 位,但我安装了 32 位版本的 Python 2.7。
我已经在这个网站和其他网站上寻找过解决方案,但他们似乎都建议删除名为 tkinter.py
的东西(我不知道这是什么)或关闭我的防火墙(除了不是防火墙的 Microsoft Security Essentials
之外,我没有启用任何防火墙。)
#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
最佳答案
问题是“python.exe”被您创建的“tkinter.py”阻碍了(即,您使用 Tk() 编写了一个程序并将其命名为 tkinter.py 并将其保存在根文件夹中 python )。仅此而已,只是确保您没有将任何程序文件直接保存在 python 的根文件夹中。
关于python - IDLE 子进程启动错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24326291/