20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.74k stars 743 forks source link

PyQt5 isssue with Qt plattform plugin #239

Open LarsGroh opened 6 years ago

LarsGroh commented 6 years ago

Hi,

when I try to use PyQt5 I get the following error when I try to execute the Qt sample code:

"This application failed to start because it could not find or load the Qt platform plugin windows. Reinstalling the application may fix this problem"

I checked the files in C:\Python27\Lib\site-packages\PyQt5\plugins\platforms The "qwindows.dll" is there.

Any idea how to fix this?

rdeioris commented 6 years ago

How did you install PyQt5, with pip or manually ?

LarsGroh commented 6 years ago

I used pip: pip install python-qt5

rdeioris commented 6 years ago

Is not PyQt5 the name of the package ?

LarsGroh commented 6 years ago

I thought so as well...but: "pip install PyQt5" does not work. for python 27

Therefore I started looking for a PyQt5 Build for Python 27: https://github.com/pyqt/python-qt5

Maybe a problem with the build?

rdeioris commented 6 years ago

Oh, it looks like there are no official binary packages for python2 so you have been forced to use a third party solution.

I suppose you cannot move to python 3...

In the readme of the github repository it suggests to use:

pip install git+git://github.com/pyqt/python-qt5.git

for a recent version

LarsGroh commented 6 years ago

After months I got back to this issue. I installed qt 5 as suggested.

Unfortunately a simple example like this caused Unreal to freeze and then to crash:

from PyQt5 import QtWidgets; new = QtWidgets.QWidget(); new.show()

Any ideas?

unbit commented 6 years ago

Have you followed the tutorial (in the README) on how to implement the qt loop ? Just spawning widgets is not enough. In addition to this i strongly suggest PySide2 as wrapper

LarsGroh commented 6 years ago

Just tried the tutorial with the qt loop and replaced PySide2 with PyQt5. Now I am getting the inital error again, that the windows plugin was missing.

The reason to use PyQt5 instead of PySide2 is that we use Python 2.7. To my knowledge there is no version of PySide2 for Python 2.7. But saying this I relize that other applications (e.g. Maya) use PySide2 with Python 2.7. So not sure how to get this working within Unreal.

unbit commented 6 years ago

Oh ok, well in such a case you need to stick with PyQt5, just ensure to build the ticker loop (should be easy to adapt for PyQT5)

LarsGroh commented 6 years ago

Alright... Seems like the path to the windows plugins of qt is not automatically set- Setting this environment variable solves the issue:

QT_QPA_PLATFORM_PLUGIN_PATH = C:\Python27\Lib\site-packages\PyQt5\plugins\platforms

Solution found on: https://blog.abstractfactory.io/pyqt5-1-1-for-python-2-7/

Though setting the varible on runtime as suggested on the page does not solve the issue. Decided to set it in the system.