Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pyinstaller - "Fatal error ! Failed to execute script" when using multiprocessing.freeze_support

I am using pyinstaller(v3.2.1) to build a --onefile windows exe. I am using multiprocessing within my python (v3.5.3) script. I have implemented the below mentioned workaround for windows.

Recipe Multiprocessing

Logically, my python script does not span multiple process unless required / conditions are met and is working as expected. The issue I have is that, whenever multiple processes are involved, everything seems fine. But in case, if multiprocess is not involed, the below "Fatal: Could not execute the script" dialog box flashes for couple of seconds or more and then disappears still returning the expected results.

enter image description here

Is there anything I am missing that is causing the fatal error dialog to appear and disappear ? I suspect the multiprocessing.freeze() statement right after if __name__ == __main__ : might be causing the issue when new processes are not created!

like image 543
Ram Avatar asked Jun 20 '17 00:06

Ram


2 Answers

I had the same issue and followed Eugene Chabanov's advise of using pyinstaller without any special characters just pyinstaller yourapp.py, when the exe was ready I opened it using the windows CMD and it got stuck in CMD with the error:

ModuleNotFoundError: No module named 'babel.numbers'

I then ran pyinstaller again this time pyinstaller -F --hidden-import "babel.numbers" test.py and it works beautifully.

Try to see what error you get and if it is "ModuleNotFoundError" then just run pyinstaller adding --hidden-import "missing_module_name".

I hope it helps.

These people deserve the credit for helping me:

--hidden-import "missing_module_name" - M. R.

run without windowed - Eugene Chabanov

like image 178
Zishe Schnitzler Avatar answered Sep 27 '22 23:09

Zishe Schnitzler


I've had similar issue and solved it by running compile command without -windowed prefix and then launching exe file using command line. It allowed to see where the error was. Script was referring to a file that wasn't there. Error popped out on another computer, while everything was ok on mine. (because of hardcoded file in place)

like image 33
Eugene Chabanov Avatar answered Sep 27 '22 21:09

Eugene Chabanov