gpt4 book ai didi

python - py2exe 给出 EOFError

转载 作者:太空宇宙 更新时间:2023-11-04 06:35:27 25 4
gpt4 key购买 nike

我有一个简单的程序,我使用 pygame 导入声音,但它仍然是一个 CLI 程序。每当我将它编译成一个 exe 时,当我尝试运行它时它会给我一个 EOFError,它看起来像这样

Traceback (most recent call last):
File "PlanetaryDistanceFromSun.pyw", line 57, in <module>
File "PlanetaryDistanceFromSun.pyw", line 31, in main
File "PlanetaryDistanceFromSun.pyw", line 44, in Planet
EOFError: EOF when reading a line

这是一段有问题的代码:raw_input("How far is %s from the sun?"% planet)

我在 Internet 上进行了大量搜索,发现一些东西说我需要一个控制台参数,但我不明白那是什么。

最佳答案

看看这个py2exe example来自 pygame 网站:

它还包含您问题的解决方案:

This will only work for GUI apps, change "windows =" to "console =" in setup command would do the job.

相关部分是这样的(IIRC):

...
windows = [{
'script': self.script,
'icon_resources': [(0, self.icon_file)],
'copyright': self.copyright
}],
...

您必须将 windows 更改为 console

此外,this thread在 pygame-user 邮件列表上描述了同样的问题:

My guess is that you used py2exe with the "windows" argument, meaning that no console is opened - without a console there is no stdin for raw_input to use. You can instead use the "console" argument in your setup.py, and your exe will open a console window allowing raw_input to work.

关于python - py2exe 给出 EOFError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11959169/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com