I tried several ways to convert a .py
file to a .exe
, but it always gave me the same problem, namely that the .exe
file didn’t work. I found a solution thanks to this post, but it is not specified how to hide the console. Could someone check the post and tell me how to do it?
EDIT:
After searching I found out a solution for my problem:
import cx_Freeze
exe = [cx_Freeze.Executable("game.py", base = "Win32GUI")] # "Win32GUI" -> no console
packages = ["os", "time", "random", "io", "pygame", "base64", "paho.mqtt"]
cx_Freeze.setup(
name = "ForzaQuattro",
version = "1.0",
options = {"build_exe": {"packages": packages,
"include_files": []}},
executables = exe
)
I used cx_Freeze with the param base="Win32GUI"
, this will hide the console of the exe file.
After that you will just replace game.py
with the name of your python script, replace packages
with the package that you need, save that file as setup.py
and run by command prompt python setup.py build
.
That will genarate a directory with all what you need.