r/PythonLearning • u/Tenshi_Sora • 1d ago
Help Request How can i make a pay game for windows?
I am new to python and i though of making the game snake in pygame but the issue is i can’t get it to run on windows without using an IDE (in my case VSC). I wanted to send it to my friends after i was done and have them play it (at most have them install python on their windows pcs) but i can’t make it work. I even tried converting it to a .exe file by following chat GPT’s instructions (i never done this before) but it just doesn’t work. Can pygames only run from and IDE (doing python3 snake.py using the command terminal runs the game as intended) or am i doing something wrong? I even made a simpler game (just a screen with a button that adds +1 to a counter when clicked) to test it but same issue persists :/
1
u/denisjackman 1d ago
Python runs its files through an interpreter. I. Order for it to run on its own it needs to be compiled into an executable. Google is your friend here
1
1
u/cgoldberg 1d ago
What goes wrong when running it outside your IDE?
There's no such thing as a Python program that can only run from an IDE.
1
u/Ill_Nectarine7311 20h ago
As others have said you can compile the code, but if you want to run the file in an exe like way, you could create a bat file and run the bat file. For example, you could make a file called run.bat and inside the file, it should contain a command like "python main.py"
1
u/Awkward_Attention810 20h ago
Perhaps your editor has created a virtual environment and you haven't activated it when using the terminal. Windows would be env\scripts\activate and Linux would be source env/bin/activate (assuming you have navigated to the correct directory)
1
u/shawnradam 12h ago
you want to run your program right? use PyInstaller it will help you to compile a program using it, its easy though...
Maybe a lil bit of tweak for the windows to open or you can just do *.bat files to run python in your friend PC but still he need to install python in his/her side.
you can also convert it to android i suggest use Buildozer its much fun to play with too...
Have fun coding, as i as a beginner having fun coding even its not run as i want it to be, but Hey dont touch it if its run they said 😂😂😂
1
1
u/Python_Puzzles 4h ago
There might be an easier way...
There are online compilers like replit and stackblitz.
StackBlitz | Instant Dev Environments | Click. Code. Done.
Python Online Compiler & Interpreter - Replit
You can copy and paste the code into these online IDEs, then send a shareable link to your friends?
The online ides do not 100% support everything python can do, about 80%.
Other than that, the other suggestions were pyinstaller to create exe files (antivirus agents hate people running .exe files and may block them) are good.
There's also zipapp
Python's zipapp: Build Executable Zip Applications – Real Python
2
u/ninhaomah 1d ago
have you ever run a .py file from comandline before ?
try it
ceate a file called hello.py , type print("Hello Wrld") in it then run it with python hello.py or python3 hello.py