PySide to PySide2


Hi, dev,

I have my UI from QT Designer and I run it with a code in PyCharm successfully:

from PySide.QtGui import *

from UI import createScene_Main

class CreateScene(QWidget, createScene_Main.Ui_CreateScene):
    def __init__(self):
        super(CreateScene, self).__init__()

        # SETUP UI

app = QApplication([])
CS = CreateScene()

But if I run this code in Houdini (changing PySide to PySide2 in this code and in UI file as well) I get an error: NameError: name 'QWidget' is not defined. How can I fix it?

Also. I cant Install PySide2 on my Windows PC. Running in command prompt pip install PySide2 raises an error:
Could not find a version that satisfies the requirement PySide2 (from versions: ) No matching distribution found for PySide2


long story short - PySide and PySide2 are not interchangable - use this to facilitate that:


Thanks, leocov! Sorry, I was not clear enough, I don`t need to interchange anything, I need to launch a UI created in QT Designer with PySide2, if its possible. Do I need to use QT Designer shipped with PySide2 for that? If so, then I suppose I need to install PySide2 and this is one of the issues I mention.


Sorry I miss-read that. I don’t use QtDesigner myself, so i don’t know if your ui files will be cross compatible.

The problem with the code you posted (that launches your ui?) is still that you are trying to instantiate a QWidget and that class does not exist in PySide - you can rewrite that code using to get around this if you need to support PySide2 and PySide.


Any thoughts why I cant install PySide2 with pip?


What version of python?
Currently pyside2 only supports python3.5+


Got it. I thought it could work with Python27.


I think the limiting factor is that the default compilers it targets aren’t supported for python2.7.
But if you do something similar to Autodesk and compile your own version of python27 with that compiler, you should also be able to build a version of PySide2 for it.

But this is a whole lot of work, and you’d have to distribute you’re custom version of python to any users of your tool.


Yeah, I am trying to keep thing simple. I found the way to load QTDesigner 2.7 UI files in Houdini, so for now I am good.

Thanks everybody!


This is something I had to deal with quite a bit when I started out with Maya UI.

The differences don’t seem to be very well documented but all you really need to understand is that when Qt updated from Qt4 to Qt5, a whole bunch of stuff (mostly widgets) was moved from QtGui into the (new as of Qt5) QtWidgets package. PySide is a binding to Qt4, whereas PySide2 is a binding to Qt5.

For your original example, all you have to do is change the import to this

from PySide2.QtWidgets import *

or if you want to be prepared for all cases…

from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import *

As leocov mentioned, you can avoid the compatibility problem by using, which basically just tries to import every possible binding and sends you back the one that is successful, so it’ll be compatible for both PySide and PySide2. I would recommend using it, especially if you want to hand your code off to someone else and be sure it will work on older versions of Houdini.

One last note on using… It’s set up to be used like a Qt5 binding, so it includes QtWidgets. SO, for whatever version of designer you used, it’ll be compatible if you use

from Qt.QtWidgets import *
from Qt.QtGui import *
from Qt.QtCore import *

Hope this helps!


You can find PySide2 wheels here, which you can download and install with pip:

And there are versions of PySide2 for Python 2.7, too.


Good find though, those are for Qt 5.9, the latest is 5.11, which is when they appeared to drop python 2. It appears that PyQt5 also dropped support for python2 with the 5.11 version.


In the parent directories you can find the 5.11 wheels:

It looks like they dropped Python 2 on Windows only, but the first 5.11 versions have a Windows Python 2 version:


I downloaded wheel for windows, trying to install and get error:

PySide2-5.9.0a1.dev1528391040-5.9.6-cp35.cp36-none-win_amd64.whl is not a supported wheel on this platform.


What version of python?

cp35.cp36 in the name PySide2-5.9.0a1.dev1528391040-5.9.6-cp35.cp36-none-win_amd64.whl seems to imply cPython 3.5 / 3.6.


To install the PySide2 version closest to 3ds Max 2019, you can use use this command to do it with pip:

pip install --index-url= pyside2 --trusted-host

See notice here


Ended up with this solution: