Nuke 11 and Pyside2

If you have made Nuke tools that rely heavily on Pyside, the move to PySide2 in Nuke 11 causes a few issues.

However, I’ve found that I can make the change quite easily with a few lines at the top and a bit of Search and Replace. A good guide has already been written on Nukepedia here, including a mention of the project, but for my tool Animation Maker, this is how I chose to do it.

My original import of the two main Qt modules was like this:

import PySide.QtCore as QtCore
import PySide.QtGui as QtGui

I’ve now changed it to this:

    # < Nuke 11
    import PySide.QtCore as QtCore
    import PySide.QtGui as QtGui
    import PySide.QtGui as QtGuiWidgets
    # >= Nuke 11
    import PySide2.QtCore as QtCore
    import PySide2.QtGui as QtGui
    import PySide2.QtWidgets as QtGuiWidgets

You’ll notice I’ve imported the same module twice under different names in both cases, and this is key to avoiding peppering your code with if/else statements. The reason you can’t just do a straight swap from PySide to PySide2, is that most of QtGui is now called QtWidgets. And the reason you can’t just import them both as the name QtGui, is because not all of QtGui has moved to QtWidgets! Anything that isn’t actually a widget, like QColor, is still in QtGui.

So I created a joint name of QtGuiWidgets, to contain QtGui in Pyside and QtWidgets in Pyside2. Then kept the QtGui namespace there for both. It’s unnecessary for Pyside, but it just allows my code to refer to either. You can call your combined module whatever you like: QtCombined, QtGui2, QtGW, QtGwidgets…. whatever makes sense.

It then remained for me to do a search for QtGui in my code and replace all of them with QtGuiWidgets. I then ran the code to find any that it failed on, and put those back to QtGui. Once I’d found them all, it worked.


QtGui.QPushButton()         #old
QtGuiWidgets.QPushButton()  #new

I did find one example where a method name had changed, so I had to do a try/except on that line, but aside from that everything works the same.

Here’s some more examples of methods that need to be moved to the combined module name (probably not a complete list):


And here’s some more examples of methods that still belong to QtGui (also probably not a complete list):


Incidentally that one changed method name I came across was solved with this:



That’s it. You may find that this approach isn’t suited to your projects, but hope this helps someone out there.


About davemne
VFX artist, developer and musician from the UK.

2 Responses to Nuke 11 and Pyside2

  1. Sridharan Kaliyamoorthy says:

    Hi thanks for ur useful information.

    i have updated Pyside as u did.

    i am getting following error in QWidget

    File “C:/Users/sridharan.kay/.nuke/”, line 550, in
    class KeySequenceWidget(QtGui.QWidget):
    AttributeError: ‘module’ object has no attribute ‘QWidget’

    can u please help me with this issue??


    • davemne says:

      If you have followed the example I gave, then QtWidget belongs in the combined QtGuiWidgets module, not QtGui. Where you have QtGui.QWidget, change it to the combined module name: eg QtGuiWidgets.QWidget

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: