Can't run my pyinstaller made .exe app with PyQt5 on Windows 10?

1

On Win10 64bit I installed PyQt5_5.4.1 for Python3.4.3. I need 3.4.3 for supporting XP clients and this is the last version that can be installed on XP. PyQt5 installed itself in python3.4.3 folder C:\Python34 and I can see it in PATH C:\Python34\Lib\site-packages\PyQt5

When I run my script with python myscript.py everything is fine, the gui window shows. However, when I try to run an .exe file from that script created with pyinstaller like this pyinstaller myscript.py --onefile I get an error:

Qt: Untested Windows version 10.0 detected!
This application failed to start because it 
could not find or load the Qt platform plugin "windows".

Reinstalling the application may fix this problem.

This code I have in myscript.py:

from PyQt5 import QtWidgets, QtCore, QtGui

Is there a fix for this problem? I tried reinstaling PyQt5 but no luck.

Hrvoje T

Posted 2018-03-06T06:43:24.663

Reputation: 1 809

We're having the same problem in our application, we tried building on Windows 10 rather than on Windows 7 but this didn't help. Also it seems like it works on some Win10 systems but not on others. PyQt version: 5.10 Python version: 3.6 – sunyata – 2018-05-07T10:23:50.087

1pyinstaller just sucks. And the more saddest part is it is the best available tool in python environment. I spent my weeks to generate fully exetubale file from my big python project with no result. So this makes python sucks :/ – tolgayilmaz – 2018-08-23T10:04:49.563

Answers

0

Make a hook file in your project directory. Name it hook-PyQt5.py for example:

from PyInstaller.utils.hooks import qt_plugins_binaries
# Fixed the issue: could not find or load the Qt platform plugin "windows".
binaries = qt_plugins_binaries('platforms', 'PyQt5')

In the Pyinstaller spec file, add a parameter

hookspath=['./']

to Analysis object:

a = Analysis(
    ...
    hookspath=['./'],
    ...
)

or specifiy an argument "--additional-hooks-dir" to commandline if you use PyInstaller directly.

python -m PyInstaller --additional-hooks-dir="./" <your-script>

Jruv

Posted 2018-03-06T06:43:24.663

Reputation: 101