简体   繁体   中英

How do I convert a python 3 file with pygame to an exe

I've already tried cx_FREEZE, but it crashes on install. I don't remember what else I tried but it obviously also didn't work. The FILE is python 3. It uses PYGAME. I need to convert it to an EXE. I tried the "Solution" here: How can I compile a python 3.3 program (which uses pygame) into a Windows executable? , 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.

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 script looks like: 脚本的样子:

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'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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