Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PySide2 seems corectly Installed but fails to load
QtWS25 Last Chance

PySide2 seems corectly Installed but fails to load

Scheduled Pinned Locked Moved Unsolved Qt for Python
11 Posts 3 Posters 2.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Silenzio76
    wrote on last edited by
    #1

    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 )
    0_1561292259698_Cattura2.PNG

    jsulmJ 1 Reply Last reply
    0
    • S Silenzio76

      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 )
      0_1561292259698_Cattura2.PNG

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @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?

        S Offline
        S Offline
        Silenzio76
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        0
        • DenniD Offline
          DenniD Offline
          Denni
          wrote on last edited by
          #4

          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?

          madness... is like gravity, all takes is a little... push -- like from an unsolvable bug

          S 1 Reply Last reply
          1
          • DenniD Denni

            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?

            S Offline
            S Offline
            Silenzio76
            wrote on last edited by Silenzio76
            #5

            @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, ...

            jsulmJ 1 Reply Last reply
            0
            • S Silenzio76

              @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, ...

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Silenzio76 Can you show the exact error?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Silenzio76 Can you show the exact error?

                S Offline
                S Offline
                Silenzio76
                wrote on last edited by Silenzio76
                #7

                @jsulm et voilĂ !!
                0_1561454965276_Cattura.PNG

                the modules installed(PyQt5 already updated):
                0_1561455021057_Cattura2.PNG

                jsulmJ 1 Reply Last reply
                0
                • S Silenzio76

                  @jsulm et voilĂ !!
                  0_1561454965276_Cattura.PNG

                  the modules installed(PyQt5 already updated):
                  0_1561455021057_Cattura2.PNG

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  S 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @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.

                    S Offline
                    S Offline
                    Silenzio76
                    wrote on last edited by
                    #9

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

                    1 Reply Last reply
                    0
                    • DenniD Offline
                      DenniD Offline
                      Denni
                      wrote on last edited by
                      #10

                      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 TestProgram.py" and copy the following into a text document and name it "TestProgram.py"

                      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()
                                  brush.setColor(Qt.blue)
                                  brush.setStyle(Qt.SolidPattern)
                                  return brush
                                   
                              elif role == Qt.BackgroundRole:
                                  brush = QBrush()
                                  brush.setColor(Qt.yellow)
                                  brush.setStyle(Qt.SolidPattern)
                                  return brush
                               
                              elif role == Qt.FontRole:
                                  font = QFont()
                                  font.setBold(True)
                                  font.setPointSize(10)
                                  return font
                                   
                              return super().headerData(section, orientation, role)
                       
                      class ItemDsplyr(QTreeView):
                          def __init__(self):
                              QTreeView.__init__(self)
                         
                              self.model = CustomItemModel(0, 3)
                              self.model.setHorizontalHeaderLabels(['Column1', 'Column2', 'Column3'])
                         
                              self.setModel(self.model)
                              self.clicked.connect(self.itemSingleClicked)
                        
                          def itemSingleClicked(self, index):
                              Item = self.selectedIndexes()[0]
                              ItemVal = Item.model().itemFromIndex(index).text()
                              print("Item Clicked:",ItemVal)
                        
                          def SetContent(self):
                              self.model.setRowCount(0)
                        
                              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):
                              QWidget.__init__(self)
                        
                              self.MainWin = parent
                        
                              self.ItemDsply = ItemDsplyr()
                              self.ItemDsply.SetContent()
                        
                              CntrPane = QSplitter(Qt.Horizontal, self)
                              CntrPane.addWidget(QTextEdit())
                              CntrPane.addWidget(self.ItemDsply)
                              CntrPane.setSizes([75,200])
                        
                              hbox = QHBoxLayout(self)
                              hbox.addWidget(CntrPane)
                        
                              self.setLayout(hbox)
                        
                          @property
                          def MainWin(self):
                              return self.__parent
                        
                          @MainWin.setter
                          def MainWin(self, value):
                              self.__parent = value
                        
                      class Window(QMainWindow):
                          def __init__(self, parent=None):
                              super(Window, self).__init__(parent)
                              self.setCentralWidget(CenterPane(self))
                        
                      if __name__ == "__main__":
                          qApp = QApplication([])
                          qApp.setStyle("fusion")
                          GUI = Window()
                          GUI.show()
                          sys.exit(qApp.exec_())
                      

                      madness... is like gravity, all takes is a little... push -- like from an unsolvable bug

                      S 1 Reply Last reply
                      0
                      • DenniD Denni

                        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 TestProgram.py" and copy the following into a text document and name it "TestProgram.py"

                        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()
                                    brush.setColor(Qt.blue)
                                    brush.setStyle(Qt.SolidPattern)
                                    return brush
                                     
                                elif role == Qt.BackgroundRole:
                                    brush = QBrush()
                                    brush.setColor(Qt.yellow)
                                    brush.setStyle(Qt.SolidPattern)
                                    return brush
                                 
                                elif role == Qt.FontRole:
                                    font = QFont()
                                    font.setBold(True)
                                    font.setPointSize(10)
                                    return font
                                     
                                return super().headerData(section, orientation, role)
                         
                        class ItemDsplyr(QTreeView):
                            def __init__(self):
                                QTreeView.__init__(self)
                           
                                self.model = CustomItemModel(0, 3)
                                self.model.setHorizontalHeaderLabels(['Column1', 'Column2', 'Column3'])
                           
                                self.setModel(self.model)
                                self.clicked.connect(self.itemSingleClicked)
                          
                            def itemSingleClicked(self, index):
                                Item = self.selectedIndexes()[0]
                                ItemVal = Item.model().itemFromIndex(index).text()
                                print("Item Clicked:",ItemVal)
                          
                            def SetContent(self):
                                self.model.setRowCount(0)
                          
                                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):
                                QWidget.__init__(self)
                          
                                self.MainWin = parent
                          
                                self.ItemDsply = ItemDsplyr()
                                self.ItemDsply.SetContent()
                          
                                CntrPane = QSplitter(Qt.Horizontal, self)
                                CntrPane.addWidget(QTextEdit())
                                CntrPane.addWidget(self.ItemDsply)
                                CntrPane.setSizes([75,200])
                          
                                hbox = QHBoxLayout(self)
                                hbox.addWidget(CntrPane)
                          
                                self.setLayout(hbox)
                          
                            @property
                            def MainWin(self):
                                return self.__parent
                          
                            @MainWin.setter
                            def MainWin(self, value):
                                self.__parent = value
                          
                        class Window(QMainWindow):
                            def __init__(self, parent=None):
                                super(Window, self).__init__(parent)
                                self.setCentralWidget(CenterPane(self))
                          
                        if __name__ == "__main__":
                            qApp = QApplication([])
                            qApp.setStyle("fusion")
                            GUI = Window()
                            GUI.show()
                            sys.exit(qApp.exec_())
                        
                        S Offline
                        S Offline
                        Silenzio76
                        wrote on last edited by
                        #11

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

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved