10

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!

Ram
  • 575
  • 2
  • 8
  • 18
  • 1
    Update: When enabling console in pyinstaller, this error does not show up and everything seems fine. But I just wanted to get rid of the the console which servers no purpose – Ram Jun 20 '17 at 19:23

7 Answers7

10

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

Zishe Schnitzler
  • 151
  • 2
  • 10
5

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)

Eugene Chabanov
  • 491
  • 5
  • 9
4

This error is often associated with a script that request some data from a directory and the directory isn't built into the exe.

If your script has some sort of data from somewhere, be sure that the data files that are in your source folder are also in the frozen app.

To add data files to the frozen app, see http://pyinstaller.readthedocs.io/en/latest/spec-files.html#adding-files-to-the-bundle

userPyGeo
  • 3,631
  • 4
  • 14
  • 24
2

After a glorious fight with this issue, I found that my modules were installed in my IDE rather than my actual python run environment. This resulted in everything working perfectly when I ran in the IDE but it failed to reference the modules when I ran the .exe. To solve this I opened the directory where my .py file was located in my cmd line and simply re-installed my dependencies there and everything worked. I hope this works for you because I was beating my head against the wall for days without finding any solutions online.

0

Try running as Admin. I had the same problem because I wanted to create some files at "Program Files".

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Fe3back
  • 924
  • 7
  • 15
0

After a long time researching I found two issues with my code:

  1. pynput only works with 1.6.8 (pip install pynput==1.6.8) See answer from Sandeep
  2. I had an icon iconbitmap(r'icon.ico') in my file. This icon file was not found when processing. I replaced it with the full path starting 'C:....' and it worked.

I was able to troubleshoot (sometimes it showed errors sometimes not) by typing YourProgramName.exe in terminal (make sure your in the right directory). Then it shows what doesn't work out.

Philip
  • 31
  • 4
0

I faced the same error while trying to convert a .py file to a .exe.

The problem in my case was that I imported a library in my script that wasn't used by the rest of the code. The weird thing is, that VS wasn't complaining about the fact that this library was totally useless.

So as a simple first step I would recommend: Go through your script and remove any redundancies.