Pyblish and Maya 2020

Hi,

I’m trying to get Pyblish running to do some tests for our pipeline. It works fine in 2019 but clicking on file>publish in maya 2020 I get the following error:

Error: AttributeError: file C:\Users\niels\pyblish\pyblish_maya\lib.py line 63: ‘PySide2.QtCore.QCoreApplication’ object has no attribute ‘topLevelWidgets’

I Use python 2.7 as maya still has this version and my PYTHONPATH is pointing to a local pyqt install grabbed from this doc: https://github.com/pyqt/python-qt5/wiki/Installation

Any clue’s in what i’m missing?

Hi @Niels_Medemblik, welcome aboard!

From looking at the line referenced in the error, it looks like this.

    parent = next(
        o for o in QtWidgets.QApplication.instance().topLevelWidgets()
        if o.objectName() == "MayaWindow"
    )

Where QtWidgets is coming from .vendor.Qt import QtWidgets, QtGui, so odds are there’s a need to update the bundled Qt.py.

As a quick test, try dropping the latest release into the pyblish_maya/vendor/Qt.py file and see whether the problem goes away. If so, pyblish_maya needs a fresh Qt.py to go with Maya 2020.

Heey Marcus,

Thanks for the quick response! I’m afraid I didn’t give enough information. I already fiddled with the Qt.py after I read something about it in the gitter chat. With the original Qt.py maya2019 works fine and maya2020 doesnt get the pyblish button due to this error:

Failed to execute userSetup.py
Traceback (most recent call last):
File “C:\Users\niels\pyblish\pyblish_maya\pythonpath\userSetup.py”, line 3, in
import(“pyblish_maya”)
File “C:\Users\niels\pyblish\pyblish_maya_init_.py”, line 3, in
from .lib import (
File “C:\Users\niels\pyblish\pyblish_maya\lib.py”, line 16, in
from .vendor.Qt import QtWidgets, QtGui
File “C:\Users\niels\pyblish\pyblish_maya\vendor\Qt.py”, line 446, in
cli(sys.argv[1:]) if name == “main” else init()
File “C:\Users\niels\pyblish\pyblish_maya\vendor\Qt.py”, line 393, in init
binding = binding()
File “C:\Users\niels\pyblish\pyblish_maya\vendor\Qt.py”, line 239, in _pyside2
_remap(QtCore, “QStringListModel”, QtGui.QStringListModel)
AttributeError: ‘module’ object has no attribute ‘QStringListModel’

So after I update the Qt.py(tested it also with your Qt.py) maya2019 still works fine and maya2020 gets the pyblish button, but when you press it it errors with

‘PySide2.QtCore.QCoreApplication’ object has no attribute ‘topLevelWidgets’

Ah. So this is an issue of pyblish_maya which admittedly I’m not sure many people are still using, because you can technically run Pyblish without it. However it does add a nice little Pyblish publish menu if that’s what you need. :slight_smile:

Anyway, the thing with Maya 2020 is that things have changed with how it launches. It launches without a QApplication but instead launches with QCoreApplication instance which does not have the topLevelWidgets() method.

The trick is to not do:

instance = QtCore.QApplication.instance()
widgets = instance.topLevelWidgets()

But to do:

widgets = QtWidgets.QApplication.topLevelWidgets()

Which would be this line of code. Removing .instance() from that line should make it work.

Also, good to see you here @Niels_Medemblik (old classmates, yay!)

Heey Roy,

Good to be here and thanks! Almost worked like a charm, after I updated the code. It gave me a QStringListModel error again. But this time in the pyblish_qml/vendors/Qt.py. I replaced that Qt.py also with the one @marcus gave me(No clue if this can be done like this). But is does run now!

Yes, its all about getting the menu up there in an easy way, so I could start testing with it. How would one go about using pyblish with say pyblish_qml only? My guess is that you would need a separate script to get the button to the UI in maya right?

The Maya integration is responsible for making that button, but it isn’t something you couldn’t make yourself too.

Launching either GUI is done by calling either…

  • pyblish_lite.show()
  • pyblish_qml.show()

What the integration does is make that choice dynamic, based on which GUIs have been “registered”.

pyblish.api.register_gui("qml")
pyblish_maya.show() # Showing Pyblish QML

The idea being that Lite and QML are “factory GUIs”, with there being many more in-house or third-party ones, and the user or dev could offer a choice as to which one to use for which purpose. For just trying things out, I wouldn’t worry much about it though, and just go with one_of_the_guis.show()

Thanks @marcus and @BigRoy

I Ended up making a custom menu anyway and I use pyblish and pyblish_qml. I got the first publishes running today, thanks again for all the help!

1 Like