Converting .py to .exe & script failed to execute error - python

I am currently coding a game in python using pygame. I wanted to convert the game to a .exe to be able to share it with my class and this is my first time using auto-py-to-exe and I am not sure how to deal with this error. I followed the instructions and converted my .py file to a .exe file. When I opened the directory to run the executable, a window pops up and says "failed to execute script Game" (i called the scrip Game). Could someone please help me figure out what I am doing wrong?

Related

Issue when trying to convert .py to .exe

Hello so I'm kind of new with programming and I buildt a program with python and kivy. The issue is that I am using auto-py-to-exe to convert the py files to exe but when I do it, it doesn't work well. The primary issue is that a windows command prompt opens when I run the app and if I close it, the app closes too. The other problem is that I can't share the file to someone else so that they can run it in another computer, and what happens is that the same command prompt kind of appears but then closes and the app doesn't open at all. I would appreciate it if someone could help me to understand how I can debug it as I don't even understand the problem in the first place.
I have been looking online for other people with the same issues but I haven't find any answer that applied to my case.
Try to choose Window Based(hide the console) and it wil works
If you choose “Console Based,” the console will open after running the executable file, which is recommended if your script generates console-based outputs. However, if you don’t want to show the console outputs when running the executable file, choose “Window Based”

Fail to run the exectuable via cmd or Python

My tutor sent me an executable to run the simulation. The usage is to put the executable, settings files and initial files to the same folder and double click the executable, and the executable will generate the result text file.
Recently I try to integrate this function into my python script. The goal is when I run the python script, the script could generate the basic input file in the folder and then run the executable to generate the result. A part of the script looks like this:
path_exe = r"D:\direction\xxx.exe"
subprocess.run(path_exe,shell=True)
However, it returns:
ERROR LOADING Keyfile_0 FILE
I'm sure that the "keyfile" is in the same direction, because it works well when I double click the executable.
Then I try to run it via cmd. I drag the executable into cmd window and press enter, the same error happens.
I don't know if it is blamed on the executable, or is the code error.

trying to run outside exe file from python freezes

I'm trying to run an executable file called CDQ.exe (which is supposed to create a text file) from within a python script. I'm using os.system(CDQ.exe) to run it. When I start the python script, the program freezes upon the os.system() call. I also don't get the text file. When I opened the task manager, I found CDQ was still running, and it kept running until I ended it.
When I try to run the CDQ.exe from the windows file browser by clicking it twice, the program appears for a couple of seconds in the task manager, then it closes, and my text file appears.
The executable file was created from c++ qt, and I'm using windows.
Does anyone know what's going on?

I used pyinstaller to turn my .py file to a executable file, but it doesn't work

EDIT: I'm using the "random" library and the "os" library, could they be interfering with the file's execution?
Good morning, I'm creating a hangman game that runs all in the terminal, doesn't open any graphical window, I used pyinstaller to turn my .py file into an executable. When I run it through the command ./My_file it works normally, but if I try to run it by double clicking it doesn't open anything! Does anyone know how to solve?

Trying to turn my python code into an app so it is easily shareable

I created a python code which creates a horse racing card betting game. I would like to share this game with my friends, who have macs, who do not have python or know anything about coding so they can play it. I have tried using pyinstaller to convert the file into a stand alone executable app. I used the command
pyinstaller --windowed Horse_Race.py
This works in that it creates a build and dist folder. The dist folder contains the app of the python code. When I run the app, however, it opens briefly (about 1s) then crashes without anything ever displaying on screen. The interesting part is that I can view the package contents of the app and run the code through my terminal by running the UNIX executable file which is within the package contents of the app.
In short the executable file works, however, the app will not run, and I cannot share the file with my friends who have macs because it just shows up as a text file. If anyone knows how to fix this issue or knows another creative way I can send my game to my friends please let me know.
Thanks for your help.
here is an easy souloution that saves time and does not require knowledge.
pip install auto-py-to-exe
and then just type
auto-py-to-exe
after typing the code above a window in your web browser will open with a ghraphical gui that looks like this
click here to go to image

Categories

Resources