Skip to content

Qt platform plugin "windows" #2

Open
@mottosso

Description

@mottosso

Cannot instantiate a QApplication.

import sys
from PyQt5 import QtWidgets

app = QtWidgets.QApplication(sys.argv)

Results in:

This application failed to start because it could not find or load the Qt platfo
rm plugin "windows".

Available platform plugins are: minimal (from C:\Python27\lib\site-packages\PyQt
5\plugins\platforms), offscreen (from C:\Python27\lib\site-packages\PyQt5\plugin
s\platforms), windows (from C:\Python27\lib\site-packages\PyQt5\plugins\platform
s).

Reinstalling the application may fix this problem.

Having encountered the problem in the past, I could solve it by appending the plugins by hand like this:

import os
import sys

import PyQt5

dirname = os.path.dirname(PyQt5.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)

However this produces the same error. The odd thing is that it says it can't load the plugin, and then lists the plugin as one of the available ones. Maybe a permission issue? Yet permissions on the files are unlocked and even replacing it with the source original from the Qt installation yields the same results. Removing the plugin from the directory correctly removes it from plugins found.

depends.exe

Running depends on qwindows.dll yields a few interesting results.

depends

However each of these are available directly within the PyQt5 Python package directory.

It works

If keeping the original installation of Qt on the PATH, PyQt5 seems to work. From a terminal:

# Keeping C:\Qt\Qt5.3.0\5.3\msvc2013_64\bin on the PATH

import os
import sys

from PyQt5 import QtWidgets
app = QtWidgets.QApplication(sys.argv)
button = QtWidgets.QPushButton("Hello World")
button.show()

So there must be something within this directory which is requited by PyQt5. But copying the entire contents into the PyQt5 Python library directory yields no better results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions