Python IDLE 子进程错误? [英] Python IDLE subprocess error?

查看:73
本文介绍了Python IDLE 子进程错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IDLE 的子进程没有做联系.要么 IDLE 无法启动子进程或个人防火墙软件正在阻止连接.

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

不要以为这已经被问到了-为什么在运行非常简单的程序时偶尔会出现这种情况-然后我必须转到任务管理器&停止所有 Pythonw 进程以使其再次工作?

Don't think this has been asked-how come this comes up occasionally when running very simple programs-I then have to go to Task Manager & stop all Pythonw processes to get it to work again?

它似乎只在不同的代码位上随机发生——这是我目前正在做的——

It seems to happen randomnly on different bits of code-here is the one I'm doing at the moment-

f = open('money.txt')
currentmoney = float(f.readline())
print(currentmoney, end='')
howmuch = (float(input('How much did you put in or take out?:')))
now = currentmoney + howmuch
print(now)
f.close()
f = open('money.txt', 'w')
f.write(str(now))
f.close()

有时有效,有时无效!

推荐答案

在 Python 3.0.1 中,我在使用 Ctrl-C 中断前一次在 Idle 的 Python Shell 中运行程序然后尝试运行后出现该错误一个脚本.

In Python 3.0.1, I have gotten that error after I Ctrl-C to interrupt a previous run of a program in Idle's Python Shell and then try to run a script.

也在 3.0.1 中:假设您打开了两个空闲窗口:一个打开的用于编辑的脚本,以及空闲的 Python Shell 窗口.我发现如果您关闭 shell 窗口然后立即尝试运行脚本,它会在尝试重新打开 shell 时出现该错误 - 但如果您在两者之间稍等一下让空闲做任何连接清理,则不会它需要做.

Also in 3.0.1: Let's say you have two Idle windows open: a script open for editing in one, and Idle's Python Shell window. I have found that if you close the shell window and then immediately try to run the script, it will give that error when it tries to re-open the shell - but not if you wait a bit in between to let Idle do whatever connection clean up it needs to do.

我发现了更糟糕的错误(同样,在 v3.0.1 中 - 不确定这是否会发生在 2.x 版本中):我有一个很长的脚本 - 达到 9k 行 - 一旦它达到一定的大小,对它执行另存为"会使空闲状态崩溃.我不确定大小的确切阈值是多少 - 但在此之前,我还会遇到一些间歇性的另存为"崩溃,这似乎取决于我所做的其他事情 - 其他空闲窗口​​,外壳中有多少输出窗口也许 - 类似的东西.它可能会崩溃,您将丢失未保存的工作.

Worse bugs I have found (again, in v3.0.1- not sure if this would happen in the 2.x versions): I had a long script - getting up towards 9k lines - and once it got to a certain size, doing "save as" on it would crash Idle. I am not sure what the exact threshold was for size - but before that, I would also get some intermittent "save as" crashes that seemed to depend on what else I had going on - other Idle windows, how much output was in the shell window perhaps - stuff like that. It can crash and you will lose unsaved work.

另外 - 我经常做的一件事是打开一个临时窗口,在那里我剪切和粘贴各个有效性阶段的代码,给自己写笔记等等 - 所以不是一个有效的 python 脚本,但我有时会保存这些我可以回到他们身边.我有一个这样的文件,每次我尝试打开它都会使 Idle 崩溃 - 第一次我丢失了未保存的工作.(仅供参考:包括 PythonWin 2.5.2 在内的其他编辑器打开文件没有问题.)

Also - one thing I commonly do is have a scratch window open where I cut and paste bits of code in various stages of validity, write notes to myself, etc - so not a valid python script, but I sometimes save these so I can come back to them. I have one such file that will crash Idle every time I try to open it - and I lost unsaved work the first time. (FYI: Other editors including PythonWin 2.5.2 have no problem opening the file.)

这篇关于Python IDLE 子进程错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆