Pyinstaller - failed to execute script: why?

Viewed 327
Fatal Error Detected: Failed to execute script main

I used the following tags:

pyinstaller --onefile -w main.py

I had dependencies, so when it finished, I moved the exe file to the main directory. I'm still getting an error. I used pygame for my project. Why?

2 Answers

When you are converting a .py file into .exe, PyInstaller shows the console. If there is an error in your code, it will be displayed in the command prompt.

But if you are converting a .pyw file into .exe, the error will be returned in the form of a message box instead.

So, to see your error (it is really quick though, but it is better than nothing), simply convert your file in .py format into an .exe, to see the error in the command prompt.


But when no window has been open, if there is an error at the beginning of the script, PyInstaller will not detect it as launched, so it will not show an error.

for example this program works, even if there is an error in the code:

avkzebhrkjvzebverybvzkejhrv

I found the answer to my problem. It turns out, it had nothing to do with images. It had to do with the font. Normally, in PyCharm (maybe I'm mistaken) freesansbold.ttf is a default font. However, when PyInstaller packages the files, PyInstaller doesn't have the font downloaded by default, so it gives an error. All I had to do was scour the internet for the font, downloaded it, and it worked.

So yeah, pretty funny mistake.

Related