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’
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.
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.
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.
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 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()