PySide2 seems corectly Installed but fails to load

  • Hello,

    I had installed PySide2 to work with Qt for Python but I tryed to run some script but nothing seems to work.
    I attach 2 screenshots to better explain(sorry for my poor English)
    0_1561292236682_Cattura.PNG )

  • Lifetime Qt Champion

    @Silenzio76 How did you install PySide2?
    Also, do you call Python interpreter for which you installed PySide2?
    Do you have more than one Python installed?

  • @jsulm Hello.
    PySide2 installed using pip(2 times installed/uninstalled/installed)

    After Your Question on multiple Python instance installed I cheched it out , and attached my tree 0_1561373357543_Cattura.PNG

  • Okay as a side note consider this Python 2.7 was deprecated back in 2015 (it is now 2019) and we are on Python 3.7 so how long do you think it will be before they deprecate (stop supporting) earlier versions of Python yes I know PySide2 has not fully caught up yet but then why use PySide2 when a fully caught up version exists pyqt5. Unless you are specifically working on the PySide2 project or need it for some obscure reason moving to pyqt5 should be simple since PySide2 and pyqt5 are both based on QT5 and as such are not all that different. So I would (unless you have some extremely solid reasons for not doing so) strongly suggest upgrading to the latest versions of both Python 3.7 and pyqt5 --- then these issues of things not syncing up solidly would be a non-issue.

    Note: Part of this is a question to you in the form of why use PySide2 over pyqt5 what are the benefits or needs to do so?

  • @Denni In the meanwhile thanks to put light on my eyes.
    I was misguided on use PySide2 because I need to produce macro for a free-software and in it's tutorial is shown to use PySide(not PySide2).
    Mine it's only ignorance!
    However, I recive the same error when I switched on pyqt5.
    the software is named lexocad...
    error.. from PyQt5.QtWidgets import QApplication, ...

  • Lifetime Qt Champion

    @Silenzio76 Can you show the exact error?

  • @jsulm et voilĂ !!

    the modules installed(PyQt5 already updated):

  • Lifetime Qt Champion

    @Silenzio76 Is it possible that lexocad brings its own Python interpreter? If this is the case installing PyQt in your Python setup will not solve the problem.

  • @jsulm here they write how manage to use a external pyhon pakedge.

  • Okay my first question would be can you access Python and the PyQt libraries from the command line run and import the library. The python Path might not be in your system variables and/or PyQt might not be accessible to python.

    Better yet try and run this program from a command line my typing "Python" and copy the following into a text document and name it ""

    If you cannot run this then the issue is with your install if you can run this the issue is with Lexocad

    import sys
    from PyQt5.QtCore import *
    from PyQt5.QtGui  import *
    from PyQt5.QtWidgets import *
    class CustomItemModel(QStandardItemModel):
        def headerData(self, section, orientation, role):
            if role == Qt.ForegroundRole:
                brush = QBrush()
                return brush
            elif role == Qt.BackgroundRole:
                brush = QBrush()
                return brush
            elif role == Qt.FontRole:
                font = QFont()
                return font
            return super().headerData(section, orientation, role)
    class ItemDsplyr(QTreeView):
        def __init__(self):
            self.model = CustomItemModel(0, 3)
            self.model.setHorizontalHeaderLabels(['Column1', 'Column2', 'Column3'])
        def itemSingleClicked(self, index):
            Item = self.selectedIndexes()[0]
            ItemVal = Item.model().itemFromIndex(index).text()
            print("Item Clicked:",ItemVal)
        def SetContent(self):
            ItmRecSet = [
                {'CatgryName':'Cat-1', 'GroupName':'Run-Grp-1', 'ItemName':'Run-Itm-1'},
                {'CatgryName':'Cat-1', 'GroupName':'Run-Grp-1', 'ItemName':'Run-Itm-2'},
                {'CatgryName':'Cat-1', 'GroupName':'Run-Grp-1', 'ItemName':'Run-Itm-3'}
            for Item in ItmRecSet:
                ItmNam = QStandardItem(Item['ItemName'])
                CatNam = QStandardItem(Item['CatgryName'])
                GrpNam = QStandardItem(Item['GroupName'])
                self.model.appendRow([CatNam, GrpNam, ItmNam])
    class CenterPane(QWidget):
        def __init__(self, parent):
            self.MainWin = parent
            self.ItemDsply = ItemDsplyr()
            CntrPane = QSplitter(Qt.Horizontal, self)
            hbox = QHBoxLayout(self)
        def MainWin(self):
            return self.__parent
        def MainWin(self, value):
            self.__parent = value
    class Window(QMainWindow):
        def __init__(self, parent=None):
            super(Window, self).__init__(parent)
    if __name__ == "__main__":
        qApp = QApplication([])
        GUI = Window()

  • @Denni it works from the command line but not from lexocad, so I must fix it thank you for your kindness!

Log in to reply