Pyblish QML in Unreal

Hi,
I’m trying to implement Pyblish in Unreal editor since python has joined Unreal. All the Pyblish base modules work great. Now I’m stuck on the UI.

First of all I tried Pyblish lite in Unreal editor and it loads well (Finger crossed). The problem is on Pyblish_qml. Just having a very basic plugin and trying to launch the application, I see the main window pops up with no widgets inside and being freezing for while then go disappeared.
Screenshot bellow

For more information about my environment set up:

  • The unreal versio: 4.26.1
  • Python version is 3.7.7 (tags/v3.7.7:d7c567b08f, Mar 10 2020, 10:41:24) [MSC v.1900 64 bit (AMD64)]
  • PYQT_VERSION = 331524
  • PYQT_VERSION_STR = 5.15.4
  • The pyblish itself is on 1.8.7

According or the requirement of Pyblish qml list on https://github.com/pyblish/pyblish-qml.

requires an external Python (2 or 3) install with PyQt 5.6+ available.
Python 3.5 any platform

Seems that PyQt version meet the requirement while Python 3.7 is higher than recommended. But not sure if this difference is crucial to run Pyblish qml.

I’ve also tried to register other python executables and PyQt5 modules but still launch from Unreal console.

api.register_python_executable(“C:/Python27/python.exe”)
api.register_pyqt5(“C:/pyblish/venv/Lib/site-packages/PyQt5”)

No luck with that either. No window pops up at all and the out log is like this.

LogPython: Already installed, uninstalling…
LogPython: Pyblish QML shutdown successful.
LogPython: Traceback (most recent call last):
LogPython: File “C:\Python27\lib\runpy.py”, line 174, in _run_module_as_main
LogPython: “main”, fname, loader, pkg_name)
LogPython: File “C:\Python27\lib\runpy.py”, line 72, in run_code
LogPython: exec code in run_globals
LogPython: File "C:\Python27\lib\site-packages\pyblish_qml_main
.py", line 6, in
LogPython: from . import app
LogPython: File “C:\Python27\lib\site-packages\pyblish_qml\app.py”, line 12, in
LogPython: from . import util, compat, control, settings, ipc
LogPython: File “C:\Python27\lib\site-packages\pyblish_qml\control.py”, line 380
LogPython: yield result
LogPython: SyntaxError: ‘return’ with argument inside generator
LogPython: Using Python @ ‘C:/Python27/python.exe’
LogPython: Using PyQt5 @ ‘C:/pyblish/venv/Lib/site-packages/PyQt5’
LogPython: Targets: default

I understand that Pyblish lite was developed to maximum the capacity which is exactly Unreal is doing with QML. However the feature that I can check the details of each valiation item is too nice to ignore. I didn’t see too many other topics in forum about this yet. But still want to take a chance if anybody else happen to experience the same problem or has any idea of the issue at least?

Any support would be appreciated!

Heya, welcome to the forum (and thanks for reporting that it was down!).

I took this for a spin and managed to get QML running in Unreal.

Here is the full set of commands I ran.

import sys

# We'll need Pyblish and QML accessible to Unreal.
# This should normally be done via the environment, prior to launching Unreal
sys.path.insert(0, r"C:\Users\marcus\packages\pyblish_qml\1.11.5\python")
sys.path.insert(0, r"C:\Users\marcus\packages\pyblish_base\1.8.8\python")

from pyblish_qml import api

# Next we'll need to tell Unreal which Python and PyQt5 to use.
api.register_python_executable(r"C:\Users\marcus\packages\python\3.7.3\platform-windows\arch-AMD64\app\python.exe")
api.register_pyqt5(r"C:\Users\marcus\packages\PyQt5\5.12.2\platform-windows\os-windows-10\python-3.7\python")

# QML will look for Pyblish and itself via the environment, but since
# we're doing all this interactively, we need to augment the environment
# interactively too.
os.environ["PYTHONPATH"] = r"C:\Users\marcus\packages\pyblish_base\1.8.8\python"
os.environ["PYTHONPATH"] += r";C:\Users\marcus\packages\pyblish_qml\1.11.5\python"

# Now we're ready to launch QML.
api.show()

Let me know if you managed to spot what was done differently here from what you tried initially. I’m somewhat confident you can skip the external Python, since Unreal seems to use Python 3.7, and there are versions of PyQt5 for 3.7. With that, it’s also possible you can skip registering PyQt5 too, and just let PyQt5 reside on the global PYTHONPATH of Unreal.

If that’s true, then you should only need call api.show() and QML should pick up Unreal’s Python and PyQt5 directly. But I didn’t test that.

Hey Marcus,
Thanks a lot for your time to investigate this. Your result absolutely inspired me. After trying your command in both the editor I failed in and the vanilla UE4.26 editor I can confirm that the first one doesn’t work while vanilla editor works just fine.
I guess there are some changes to our in house editor which I will need to chase up with the engineers here. At the same time, in worst scenario do you have any suggestion if I will have to run the UI from an external interpolator while still being able to communicate with the editor interpolator? My thought is like collecting data from editor interpolator and send to the external Pyblish running qml. (Then hopefully can send the result back to editor after validation?)
Thanks again for the support. It is supreme!

Nathan, this might not have any impact but your Python installation seems to be 2.7, or at least that’s what the folder name says. Also note that the error itself is outlining functionality only available in 3.x; you cannot return from a generator in 2.7.

LogPython: File “C:\Python27\lib\site-packages\pyblish_qml\control.py”, line 380
LogPython: yield result
LogPython: SyntaxError: ‘return’ with argument inside generator
LogPython: Using Python @ ‘C:/Python27/python.exe’
LogPython: Using PyQt5 @ ‘C:/pyblish/venv/Lib/site-packages/PyQt5’
LogPython: Targets: default

Hey Claudio,
Thank you. Registering Python 2.7 was a workaround I tried. So the log was from that. I tried 3.6, 3.7 and 3.8. Neither of them help me run up Pyblish qml in my editor.
But in the end I think it’s something wrong with my editor not Pyblish itself. Just need to figure out another workaround.

Oh that is interesting. Curious to know what could have been done to the custom one to break this, there’s not much going on besides (1) loading the PyQt5 dynamic library and (2) communicating with subprocess.Popen from a threading.Thread. Pretty bare-bone and basic Python things that I can’t see how an editor, or any application really, can break.

If you find out what it is, please share if you can.