Python IDLE 子进程启动错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24326291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IDLE subprocess startup error
提问by All Day
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:
我在一个名为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."
“IDLE 的子进程没有建立连接。IDLE 无法启动个人防火墙软件的子进程正在阻止连接。”
I am using Windows 7 Ultimate 64bit, but I have the 32bit version of Python 2.7 installed.
我使用的是 64 位 Windows 7 Ultimate,但我安装了 32 位版本的 Python 2.7。
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.)
我已经在这个网站和其他网站上寻找了一个解决方案,但他们似乎都建议删除一个叫做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
回答by MSB
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.
我有同样的问题。我所做的解决了这个问题,是将我在“C:\Python33”文件夹中创建的每个 .py 文件移动到我命名为“Examples”的子文件夹中。似乎我的一个文件是导致此问题的原因。
回答by Ryan
I also had the following problem. My file was named code.py, and was working fine untill I installed Canopy, and numpy.
我也遇到了以下问题。我的文件被命名为 code.py,并且在我安装 Canopy 和 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...
我尝试重新安装python,但对我来说解决问题的只是重命名文件。我将我的文件命名为 myCode.py,一切开始正常。奇怪的问题...
回答by karthikeya
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.
问题是“python.exe”被您创建的“tkinter.py”)阻塞(即,您用 Tk() 编写了一个程序并将其命名为 tkinter.py 并将其保存在 python 的根文件夹中) . 就是这样,只要确保您没有将任何程序文件直接保存在python的根文件夹中即可。
回答by karthikeya
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.
我遇到了同样的问题,并注意到一些非常有趣的事情。我不小心命名了一个文件(在我工作的桌面文件夹内)“tkinter”(如果你用任何保留关键字重命名文件,我认为它会导致同样的问题)。每次我运行或尝试运行此文件时,它都会创建一个 pycache 文件夹,并且出现您上面提到的错误。删除错误命名的python文件解决了问题。
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!
因此 - 查找以任何保留字命名的任何文件(在您正在使用的文件夹中或实际上是根文件夹中)。删除它们。希望它会起作用!