[英]How do I convert a python 3 file with pygame to an exe
I've already tried cx_FREEZE, but it crashes on install. 我已经尝试过cx_FREEZE,但是在安装时崩溃。 I don't remember what else I tried but it obviously also didn't work. 我不记得我还尝试了什么,但是显然也没有用。 The FILE is python 3. It uses PYGAME. FILE是python3。它使用PYGAME。 I need to convert it to an EXE. 我需要将其转换为EXE。 I tried the "Solution" here: How can I compile a python 3.3 program (which uses pygame) into a Windows executable? 我在这里尝试了“解决方案”: 如何将python 3.3程序(使用pygame)编译为Windows可执行文件? , however I cannot find any documentation on how to use the program. ,但是找不到有关如何使用该程序的任何文档。
There's some sort of bug when you try to use cx_freeze with Python 3.x and Pygame. 当您尝试将cx_freeze与Python 3.x和Pygame结合使用时,会出现某种错误。
You need to include these lines of code in your main program: 您需要在主程序中包括以下代码行:
import re
includes = ["re"]
import pygame._view
This solved the problem for me. 这为我解决了问题。
And this is what my setup.py script looks like: 这就是我的setup.py脚本的样子:
from cx_Freeze import setup, Executable
exe = Executable(
script="game.py",
)
setup(
executables = [exe]
)
# go to C:\Python32 in CMD prompt and type 'c:\python32\python.exe setup.py build'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.