0

Error:

This application failed to start because it could not find or load the Qt platform plugin "windows" in "C:\Users\jsmith\AppData\Local\Temp_MEI23522\qt5_plugins\platforms".

Reinstalling the application may fix this problem.

My PyInstaller spec:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['test.py'],
             pathex=['C:\\Users\\admin\\compile'],
             binaries=[],
             datas=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)

pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='test',
          debug=False,
          strip=False,
          upx=False,
          runtime_tmpdir=None,
          console=False , icon='icon.ico')

So I ran into this problem while compiling my PyQt5 5.8.2 (with Python 3.6.1) program with the latest version of PyInstaller with pip, and, it works fine! The one-file executable works on the computer that compiled it.

But when I test it on another computer or virtual machine that doesn't have everything set up already, then, it crashes on start with this error:

could not find or load the Qt platform plugin 'windows'

So here's what I have found so far. Since I set the platform plugin path environment variable in the code, it has the path (C:\Users\jsmith\AppData\Local\Temp\_MEI23522\qt5_plugins\platforms), and I know for a fact the qwindows.dll is in there because I was able to access it through the path before the folder was automatically deleted (since it's in temp) (I've also done onedir before just to make sure it was there, it was). So does that mean it sees it but is unable to load it, or is it something else I'm missing?

Also, UPX is disabled and isn't even on my computer, so that isn't the problem.

By the way, this is not a duplicate. I have already looked on SO for similar questions and all of them were either for a different type of application or the solutions were for a different type of problem. I have looked everywhere for days and haven't found the solution.

Please guide me. Thanks.

Azeem
  • 11,148
  • 4
  • 27
  • 40
J. Doe
  • 111
  • 1
  • 1
  • 6
  • Since this is on Windows, have you run your application through Dependency Walker? Assuming Qt's Windows plugin loaded, it's possible that DLL depended on another DLL that it couldn't find. – MrEricSir Nov 27 '17 at 06:11
  • 1
    In the Qt library folder, there should be a `/plugins/platforms` folder. Copy this folder into the one where your executable is and try again. – Jepessen Nov 27 '17 at 09:10
  • @Jepessen I'm trying to do everything statically, everything in one executable. PyInstaller stores qwindows.dll in qt5_plugins/platforms in the executable, and through my script I even give Qt the path but it still doesn't load. – J. Doe Nov 27 '17 at 19:25
  • In c++ there's a command `QCoreApplication::addLibraryPath(". /") ` that solves this problem. Find something similar in your case. – Jepessen Nov 27 '17 at 19:48
  • @Jepessen Pyqt has addLibraryPath, I'm just not sure how to use it in my case. – J. Doe Nov 27 '17 at 23:00
  • @MrEricSir I'm not sure how to do that. – J. Doe Nov 28 '17 at 05:26
  • @MrEricSir Actually I lied, I just ran it through Dependency Walker and this is the result: https://i.gyazo.com/24e0bc9e2c9f11f2f02c089ad3944a4e.png (note that I did this on the computer that compiled it that can run it) – J. Doe Nov 28 '17 at 05:29

0 Answers0