简体   繁体   English

使用 auto-py-to-exe 无法将.py 转换为 exe

[英]Trouble Converting .py to ,exe with auto-py-to-exe

I am new to python and tkinter, but I made a Hangman game that uses two external text documents to get words (easy and hard).我是 python 和 tkinter 的新手,但我制作了一个 Hangman 游戏,它使用两个外部文本文档来获取单词(简单和困难)。 I want to convert it to.exe but when I try to use auto-py-to-exe, after it finishes converting, the.exe always gives a fatal error.我想将其转换为 .exe,但是当我尝试使用 auto-py-to-exe 时,在完成转换后,.exe 总是会出现致命错误。 I have tried a variety of settings (one file, one directory, including the text documents as additional files, etc) but the same thing occurs everytime.我尝试了各种设置(一个文件,一个目录,包括作为附加文件的文本文档等),但每次都会发生同样的事情。 Any suggestions for settings to use to make it work or other methods to accomplish this?对于用于使其工作的设置或其他方法来完成此操作有什么建议吗?

Thanks!谢谢!

you could do你可以做

file=open("./file.py","r")
content=file.read()
file.close()

file=open("./newfile.txt","w")
file.write(content)
file.close()

I think it will work我认为它会起作用

Have a nice day X)祝你有美好的一天 X)

What works for me when converting.py to.exe with additional imports (like tkinter) is to add "hidden-imports", it's under the "advanced" tab when you are in auto-py-to-exe.将.py 转换为带有附加导入(如 tkinter)的 exe 对我有用的是添加“隐藏导入”,当您处于自动 py 到 exe 时,它位于“高级”选项卡下。

To get it to work, add "tkinter":要让它工作,请添加“tkinter”:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM