Tuesday, October 16, 2018

[Python 3] Pyinstaller and PyQt5 : Failed to execute script 'file name'

If we have this error 'Failed to execute script' when executing an exe file, then try below and recompile it .
It is necessary to add the path of required dlls file to the system path.


1. Install Windows SDK(or visual studio 2015), and add the path to the system 'Envrionment Variables'
Windows SDK (Korean) download

For example,

     C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86



2. Add the path of PyQt5 bin folder to the system 'Envrionment Variables'
For example,

       C:\Program Files\Python36\Lib\site-packages\PyQt5\Qt\bin




or directly modify xxxxx.spec file which was created after compiling, and re-compile with xxxxx.spec file.


After this, compile python code with pyinstaller, and put ui file( GUI code created by PyQt5) in the same folder as exe file. 
: pyinstaller -F --noconsole 'filename.py'

No comments:

Post a Comment