Pyblish and Maya 2020


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\ 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:

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

As a quick test, try dropping the latest release into the pyblish_maya/vendor/ file and see whether the problem goes away. If so, pyblish_maya needs a fresh 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 after I read something about it in the gitter chat. With the original maya2019 works fine and maya2020 doesnt get the pyblish button due to this error:

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

So after I update the it also with your 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/ I replaced that 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…


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

pyblish.api.register_gui("qml") # 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

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

For completeness, this appears to have been fixed in the latest release of pyblish-maya!