I'm a beginner using python and when I found out about pygame and how cool it was I immediately started learning it. I recently finished a simple game and I want to make a desktop icon that I can click to run the script rather than having to open pycharm and click the run button. If there is a way to just run the script by clicking a desktop icon that would be awesome. Any suggestions?
Asked
Active
Viewed 262 times
0
-
PyCharm is only for creating code - when code is ready then you can run in console `python script.py`. And on Windows you can assing extension `.py` to program `python` and it will run script when you click file .py. On Linux you may use `shebang` in first line `#!/usr/bin/env python` and set it executable `chmod +x script.py` and then you can click it to run with python. You don't have to create .exe for this (if you run on your computer with installed Python). `.exe` can be useful when you want to send it to someone else (which don't have Python). – furas May 11 '22 at 17:04
1 Answers
0
Welcome to Stack Overflow. There appear to be several packages that achieve this, but from this post, cx_Freeze seems to be easy to implement.
It creates an executable (.exe
) from your Python code. Assuming you're using Windows, this should be the implementation:
from cx_Freeze import setup, Executable
base = None
if sys.platform == "win32":
base = "Win32GUI"
setup(
name="app_name",
version="0.1",
description="app_description",
executables=[Executable("app_file.py", base=base)],
)

y_arjun_y
- 31
- 1
- 3
- 5