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. libQt5Core5 missmatch (beginner)
Forum Updated to NodeBB v4.3 + New Features

libQt5Core5 missmatch (beginner)

Scheduled Pinned Locked Moved Solved Qt for Python
pyside2
16 Posts 6 Posters 3.2k Views 2 Watching
  • 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.
  • SGaistS SGaist

    Hi and welcome to devnet,

    You are mixing two different bindings which are built with two different versions of Qt. That's the issue, either use PyQt5 or PySide2 but not both at the same time.

    Oak77O Offline
    Oak77O Offline
    Oak77
    wrote on last edited by Oak77
    #3

    @SGaist and @Denni-0,

    Thank you for your suggestions, I realized I was mistaking them two bindings just for a Qt binging and a Qt library. Comes from mixed tutorials, when I tried to fix another error. And I'm back to square one here, because the original error is back, it tells me "uic" is not part of PySide2:

    Traceback (most recent call last):
      File "/home/<user>/Coding/Projects/Test1/main.py", line 3, in <module>
        from PySide2.QtWidgets import QApplication, uic
    ImportError: cannot import name 'uic'
    02:01:49: /usr/bin/python3 exited with code 1
    

    My PySide2 seems to be up-to-date (regardless of fact, that I'm unsure if I should run it as superuser):

    > pip install --upgrade PySide2
    Defaulting to user installation because normal site-packages is not writeable
    Requirement already up-to-date: PySide2 in /usr/lib64/python3.6/site-packages (5.15.0a1.dev1584103015)
    Requirement already satisfied, skipping upgrade: shiboken2==5.15.0a1.dev1584103015 in /usr/lib64/python3.6/site-packages (from PySide2) (5.15.0a1.dev1584103015)
    

    Oak

    1 Reply Last reply
    0
    • Oak77O Offline
      Oak77O Offline
      Oak77
      wrote on last edited by Oak77
      #4

      @Denni-0 said in libQt5Core5 missmatch (beginner):

      Okay first -- do your self a favor and do not use the Designer its not really meant to create quality GUIs and its just as easy to learn to do it right.

      As for this off topic comment, I decided to react in a separate answer. There are several reasons I'm testing it this way:

      1. I read such opinion before during my research, I guess it was you who wrote it. And I also read some reactions stating, that QtDesigner produces perfectly valid UI definitions. I'm not judging on that, just I'm ready to give QtDesigner a chance to compare with my decade+ experience with Windows Forms Designer. You warned me :-)
      2. I do (mecanical) engineering and production aps and pack a lot of know-how into them. They often use a lot of GUI widgets. Even though I have plenty of experience with dynamic GUI too, in most cases it's way more convenient to have graphical representation. Imagine you collected a bug list of 10 and you're going to do fixes with little GUI changes in 10 different forms with totally different logic, each with plenty of sections (frames, subframes,...). With GUI managed layouts, you may be done in half an hour, with programatically defined GUI like those (and it's quite real scenario), you have to study first each layout thoroughly and you might spend two days on the job. And I think due to nature of my otherwise simple programming, I have more experience with GUI than probably 98% of coders...
      3. Simply, I have very good graphical memmory. I remember my layouts I made 10 years back - and I really did tons of them. With written code, I hardly remember structure of what I wrote in the morning. I mean I know the logic, I know it's there, but will notorically fail to find the spot I need in any reasonable, direct way.
      4. I am looking for a certain level of productivity on creating GUI, because I do a lot of them. If I couldn't achieve it, I couldn't switch [to PyQt]. That's why the Python and not C++, by the way.

      So I want to give QtDesigner a chance. And I actually expect it will perform quite good, it's here for decades.

      Pablo J. RoginaP 1 Reply Last reply
      1
      • Oak77O Oak77

        @Denni-0 said in libQt5Core5 missmatch (beginner):

        Okay first -- do your self a favor and do not use the Designer its not really meant to create quality GUIs and its just as easy to learn to do it right.

        As for this off topic comment, I decided to react in a separate answer. There are several reasons I'm testing it this way:

        1. I read such opinion before during my research, I guess it was you who wrote it. And I also read some reactions stating, that QtDesigner produces perfectly valid UI definitions. I'm not judging on that, just I'm ready to give QtDesigner a chance to compare with my decade+ experience with Windows Forms Designer. You warned me :-)
        2. I do (mecanical) engineering and production aps and pack a lot of know-how into them. They often use a lot of GUI widgets. Even though I have plenty of experience with dynamic GUI too, in most cases it's way more convenient to have graphical representation. Imagine you collected a bug list of 10 and you're going to do fixes with little GUI changes in 10 different forms with totally different logic, each with plenty of sections (frames, subframes,...). With GUI managed layouts, you may be done in half an hour, with programatically defined GUI like those (and it's quite real scenario), you have to study first each layout thoroughly and you might spend two days on the job. And I think due to nature of my otherwise simple programming, I have more experience with GUI than probably 98% of coders...
        3. Simply, I have very good graphical memmory. I remember my layouts I made 10 years back - and I really did tons of them. With written code, I hardly remember structure of what I wrote in the morning. I mean I know the logic, I know it's there, but will notorically fail to find the spot I need in any reasonable, direct way.
        4. I am looking for a certain level of productivity on creating GUI, because I do a lot of them. If I couldn't achieve it, I couldn't switch [to PyQt]. That's why the Python and not C++, by the way.

        So I want to give QtDesigner a chance. And I actually expect it will perform quite good, it's here for decades.

        Pablo J. RoginaP Offline
        Pablo J. RoginaP Offline
        Pablo J. Rogina
        wrote on last edited by
        #5

        @Oak77 said in libQt5Core5 missmatch (beginner):

        And I also read some reactions stating, that QtDesigner produces perfectly valid UI definitions.

        One clarification just in case. I guess that @Denni-0 doesn't object the way Qt Designer creates the UI definitions (the XML data written into the .ui file).

        What he does endlessly is to complain about the Python code that it's generated taken that .ui file as input, code generated by tool pyside2-uic, compared to writing the GUI by hand with Python code.

        However, he does endlessly fail to prove with facts such claims.

        So I think you're good to go with your research :-)

        Upvote the answer(s) that helped you solve the issue
        Use "Topic Tools" button to mark your post as Solved
        Add screenshots via postimage.org
        Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        2
        • Oak77O Offline
          Oak77O Offline
          Oak77
          wrote on last edited by
          #6

          I also tried to switch to PyQt5 bindings this way:

          import sys
          from PyQt5.QtWidgets import QApplication, uic
          
          if __name__ == "__main__":
              app = QApplication([])
          
              uic.loadUi('mainw.ui')
          
              sys.exit(app.exec_())
          

          ...but I get exactly the same error:

          Traceback (most recent call last):
            File "/home/<user>/Coding/Projects/TestIS/main.py", line 3, in <module>
              from PyQt5.QtWidgets import QApplication, uic
          ImportError: cannot import name 'uic'
          11:04:59: /usr/bin/python3 exited with code 1
          

          I feel like I'm doing something really basic wrong. But I can find a lot of references to this such syntax with importing 'uic' and really can't find what's wrong.

          JonBJ jazzycamelJ 2 Replies Last reply
          0
          • Oak77O Oak77

            I also tried to switch to PyQt5 bindings this way:

            import sys
            from PyQt5.QtWidgets import QApplication, uic
            
            if __name__ == "__main__":
                app = QApplication([])
            
                uic.loadUi('mainw.ui')
            
                sys.exit(app.exec_())
            

            ...but I get exactly the same error:

            Traceback (most recent call last):
              File "/home/<user>/Coding/Projects/TestIS/main.py", line 3, in <module>
                from PyQt5.QtWidgets import QApplication, uic
            ImportError: cannot import name 'uic'
            11:04:59: /usr/bin/python3 exited with code 1
            

            I feel like I'm doing something really basic wrong. But I can find a lot of references to this such syntax with importing 'uic' and really can't find what's wrong.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #7

            @Oak77

            from PyQt5.QtWidgets import QApplication, uic

            Where did you get idea of from PyQt5/PySide2.QtWidgets import uic from?

            For PySide2:

            Do you want to read and follow approach from https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#loading-it-directly ? Essentially

            from PySide2.QtUiTools import QUiLoader
            
            ui_file = QFile("mainwindow.ui")
            ui_file.open(QFile.ReadOnly)
            
            loader = QUiLoader()
            window = loader.load(ui_file)
            window.show()
            

            For PyQt5:

            It's from PyQt5 import uic, not QtWidgets. See https://www.riverbankcomputing.com/static/Docs/PyQt5/designer.html & https://www.riverbankcomputing.com/static/Docs/PyQt5/api/uic/uic-module.html

            That's to let you load the .ui file dynamically at run-time. If you want to generate a Python class at design-time, there is (command-line tools) pyside2-uic or pyuic5 for PyQt. Or similar, search for these.

            If you want advice on which approach to take, I would say the design-time generation of classes probably gives you easier access to the UI objects created. You have to get used to running the pyuic bit whenever you change the UI in the designer.

            You probably want to make your decision about whether you want to go PySide2 or PyQt5, and stick with it. I don't know what your criteria are.

            1 Reply Last reply
            3
            • Oak77O Oak77

              I also tried to switch to PyQt5 bindings this way:

              import sys
              from PyQt5.QtWidgets import QApplication, uic
              
              if __name__ == "__main__":
                  app = QApplication([])
              
                  uic.loadUi('mainw.ui')
              
                  sys.exit(app.exec_())
              

              ...but I get exactly the same error:

              Traceback (most recent call last):
                File "/home/<user>/Coding/Projects/TestIS/main.py", line 3, in <module>
                  from PyQt5.QtWidgets import QApplication, uic
              ImportError: cannot import name 'uic'
              11:04:59: /usr/bin/python3 exited with code 1
              

              I feel like I'm doing something really basic wrong. But I can find a lot of references to this such syntax with importing 'uic' and really can't find what's wrong.

              jazzycamelJ Offline
              jazzycamelJ Offline
              jazzycamel
              wrote on last edited by
              #8

              @Oak77

              With PyQt5, first you use the pyuic5 tool that will have been installed at the same time as PyQt5 (assuming you used pip) to convert your .ui file into a python module:

              $ pyuic5 -x mainw.ui -o mainw.py

              You then import this module into your main application code and use it thus:

              from PyQt5.QtWidgets import QMainWindow
              from mainw import Ui_MainWindow
              
              class MainWindow(QMainWindow):
                  def __init__(self, parent=None, **kwargs):
                      super().__init__(parent, **kwargs)
              
                      self.ui=UI_MainWindow()
                      self.ui.setupUI(self)
              
              if __name__=='__main__':
                  from sys import argv, exit
                  from PyQt5.QtWidgets import QApplication
              
                  a=QApplication(argv)
                  m=MainWindow()
                  m.show()
                  exit(a.exec_())
              

              Hope this helps :o)

              For the avoidance of doubt:

              1. All my code samples (C++ or Python) are tested before posting
              2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
              Oak77O 1 Reply Last reply
              2
              • jazzycamelJ jazzycamel

                @Oak77

                With PyQt5, first you use the pyuic5 tool that will have been installed at the same time as PyQt5 (assuming you used pip) to convert your .ui file into a python module:

                $ pyuic5 -x mainw.ui -o mainw.py

                You then import this module into your main application code and use it thus:

                from PyQt5.QtWidgets import QMainWindow
                from mainw import Ui_MainWindow
                
                class MainWindow(QMainWindow):
                    def __init__(self, parent=None, **kwargs):
                        super().__init__(parent, **kwargs)
                
                        self.ui=UI_MainWindow()
                        self.ui.setupUI(self)
                
                if __name__=='__main__':
                    from sys import argv, exit
                    from PyQt5.QtWidgets import QApplication
                
                    a=QApplication(argv)
                    m=MainWindow()
                    m.show()
                    exit(a.exec_())
                

                Hope this helps :o)

                Oak77O Offline
                Oak77O Offline
                Oak77
                wrote on last edited by Oak77
                #9

                "With PyQt5, first you use the pyuic5 tool that will have been installed at the same time as PyQt5...."

                @jazzycamel I believe that is one of possible methods (?). I read through tutorials, posts and books and I'd swear I read explicitely, that those are two different ways to use UI file. Also I'm following tutorials for this method.

                I know I can convert, but I deliberately want to use UI files at this stage, because I'd prefer to use them at design stage. When the particular forms are stable, I might get into habit to export them, if it will help performance noticeably.
                I'm not saying I won't end up using this method as standard later, I'm only learning at this stage.

                I'll try the conversion as per your code and instructionss as another training, it won't hurt me :-).

                EDIT:
                I get command-not-found when trying to run:

                pyuic5 -x mainw.ui -o mainw.py
                

                So I'm starting to think those two issues are connected.

                Again, I do have PyQt5 installed:

                > pip install --upgrade PyQt5
                Defaulting to user installation because normal site-packages is not writeable
                Requirement already up-to-date: PyQt5 in /home/<user>/.local/lib/python3.6/site-packages (5.14.1)
                Requirement already satisfied, skipping upgrade: PyQt5-sip<13,>=12.7 in /home/<user>/.local/lib/python3.6/site-packages (from PyQt5) (12.7.1)
                

                ...but the strange "Defaulting to user installation" message might be a clue. My python is in /usr/bin/Python3, my libraries in /usr/lib64/python/ (symlink), but here it looks into user directory /home/<user>/.local/lib/python3.6/site-packages. When I run following command:

                > python -m site
                sys.path = [
                    '/home/libor/Coding/Projects/Test2',
                    '/usr/lib/python27.zip',
                    '/usr/lib64/python2.7',
                    '/usr/lib64/python2.7/plat-linux2',
                    '/usr/lib64/python2.7/lib-tk',
                    '/usr/lib64/python2.7/lib-old',
                    '/usr/lib64/python2.7/lib-dynload',
                    '/usr/lib64/python2.7/site-packages',
                    '/usr/lib64/python2.7/site-packages/PIL',
                    '/usr/local/lib64/python2.7/site-packages',
                    '/usr/local/lib/python2.7/site-packages',
                    '/usr/lib64/python2.7/site-packages/gtk-2.0',
                    '/usr/lib/python2.7/site-packages',
                    '/usr/local/lib64/python2.7/site-packages',
                    '/usr/local/lib/python2.7/site-packages',
                ]
                USER_BASE: '/home/<user>/.local' (exists)
                USER_SITE: '/home/<user>/.local/lib/python2.7/site-packages' (doesn't exist)
                ENABLE_USER_SITE: True
                

                ...I think I see the evil: USER_SITE points to different site-packages, from Python 2.7.

                So can I simply do following??

                export USER_SITE=/home/<user>/.local/lib/python3.6/site-packages 
                

                Does it look like a solution?

                Pablo J. RoginaP JonBJ 2 Replies Last reply
                0
                • Oak77O Oak77

                  "With PyQt5, first you use the pyuic5 tool that will have been installed at the same time as PyQt5...."

                  @jazzycamel I believe that is one of possible methods (?). I read through tutorials, posts and books and I'd swear I read explicitely, that those are two different ways to use UI file. Also I'm following tutorials for this method.

                  I know I can convert, but I deliberately want to use UI files at this stage, because I'd prefer to use them at design stage. When the particular forms are stable, I might get into habit to export them, if it will help performance noticeably.
                  I'm not saying I won't end up using this method as standard later, I'm only learning at this stage.

                  I'll try the conversion as per your code and instructionss as another training, it won't hurt me :-).

                  EDIT:
                  I get command-not-found when trying to run:

                  pyuic5 -x mainw.ui -o mainw.py
                  

                  So I'm starting to think those two issues are connected.

                  Again, I do have PyQt5 installed:

                  > pip install --upgrade PyQt5
                  Defaulting to user installation because normal site-packages is not writeable
                  Requirement already up-to-date: PyQt5 in /home/<user>/.local/lib/python3.6/site-packages (5.14.1)
                  Requirement already satisfied, skipping upgrade: PyQt5-sip<13,>=12.7 in /home/<user>/.local/lib/python3.6/site-packages (from PyQt5) (12.7.1)
                  

                  ...but the strange "Defaulting to user installation" message might be a clue. My python is in /usr/bin/Python3, my libraries in /usr/lib64/python/ (symlink), but here it looks into user directory /home/<user>/.local/lib/python3.6/site-packages. When I run following command:

                  > python -m site
                  sys.path = [
                      '/home/libor/Coding/Projects/Test2',
                      '/usr/lib/python27.zip',
                      '/usr/lib64/python2.7',
                      '/usr/lib64/python2.7/plat-linux2',
                      '/usr/lib64/python2.7/lib-tk',
                      '/usr/lib64/python2.7/lib-old',
                      '/usr/lib64/python2.7/lib-dynload',
                      '/usr/lib64/python2.7/site-packages',
                      '/usr/lib64/python2.7/site-packages/PIL',
                      '/usr/local/lib64/python2.7/site-packages',
                      '/usr/local/lib/python2.7/site-packages',
                      '/usr/lib64/python2.7/site-packages/gtk-2.0',
                      '/usr/lib/python2.7/site-packages',
                      '/usr/local/lib64/python2.7/site-packages',
                      '/usr/local/lib/python2.7/site-packages',
                  ]
                  USER_BASE: '/home/<user>/.local' (exists)
                  USER_SITE: '/home/<user>/.local/lib/python2.7/site-packages' (doesn't exist)
                  ENABLE_USER_SITE: True
                  

                  ...I think I see the evil: USER_SITE points to different site-packages, from Python 2.7.

                  So can I simply do following??

                  export USER_SITE=/home/<user>/.local/lib/python3.6/site-packages 
                  

                  Does it look like a solution?

                  Pablo J. RoginaP Offline
                  Pablo J. RoginaP Offline
                  Pablo J. Rogina
                  wrote on last edited by
                  #10

                  @Oak77 as a brief summary, there are 3 methods to create your GUIs:

                  1. Hand-coded GUI
                  2. Tool-coded GUI from .ui file (using pyside2-uic or pyqt-uic)
                  3. Loading of .ui file at runtime

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  1 Reply Last reply
                  3
                  • Oak77O Oak77

                    "With PyQt5, first you use the pyuic5 tool that will have been installed at the same time as PyQt5...."

                    @jazzycamel I believe that is one of possible methods (?). I read through tutorials, posts and books and I'd swear I read explicitely, that those are two different ways to use UI file. Also I'm following tutorials for this method.

                    I know I can convert, but I deliberately want to use UI files at this stage, because I'd prefer to use them at design stage. When the particular forms are stable, I might get into habit to export them, if it will help performance noticeably.
                    I'm not saying I won't end up using this method as standard later, I'm only learning at this stage.

                    I'll try the conversion as per your code and instructionss as another training, it won't hurt me :-).

                    EDIT:
                    I get command-not-found when trying to run:

                    pyuic5 -x mainw.ui -o mainw.py
                    

                    So I'm starting to think those two issues are connected.

                    Again, I do have PyQt5 installed:

                    > pip install --upgrade PyQt5
                    Defaulting to user installation because normal site-packages is not writeable
                    Requirement already up-to-date: PyQt5 in /home/<user>/.local/lib/python3.6/site-packages (5.14.1)
                    Requirement already satisfied, skipping upgrade: PyQt5-sip<13,>=12.7 in /home/<user>/.local/lib/python3.6/site-packages (from PyQt5) (12.7.1)
                    

                    ...but the strange "Defaulting to user installation" message might be a clue. My python is in /usr/bin/Python3, my libraries in /usr/lib64/python/ (symlink), but here it looks into user directory /home/<user>/.local/lib/python3.6/site-packages. When I run following command:

                    > python -m site
                    sys.path = [
                        '/home/libor/Coding/Projects/Test2',
                        '/usr/lib/python27.zip',
                        '/usr/lib64/python2.7',
                        '/usr/lib64/python2.7/plat-linux2',
                        '/usr/lib64/python2.7/lib-tk',
                        '/usr/lib64/python2.7/lib-old',
                        '/usr/lib64/python2.7/lib-dynload',
                        '/usr/lib64/python2.7/site-packages',
                        '/usr/lib64/python2.7/site-packages/PIL',
                        '/usr/local/lib64/python2.7/site-packages',
                        '/usr/local/lib/python2.7/site-packages',
                        '/usr/lib64/python2.7/site-packages/gtk-2.0',
                        '/usr/lib/python2.7/site-packages',
                        '/usr/local/lib64/python2.7/site-packages',
                        '/usr/local/lib/python2.7/site-packages',
                    ]
                    USER_BASE: '/home/<user>/.local' (exists)
                    USER_SITE: '/home/<user>/.local/lib/python2.7/site-packages' (doesn't exist)
                    ENABLE_USER_SITE: True
                    

                    ...I think I see the evil: USER_SITE points to different site-packages, from Python 2.7.

                    So can I simply do following??

                    export USER_SITE=/home/<user>/.local/lib/python3.6/site-packages 
                    

                    Does it look like a solution?

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #11

                    @Oak77 said in libQt5Core5 missmatch (beginner):

                    python -m site

                    Before you go any further! Under Linux python executes Python 2. That's why you're seeing all those python2.7 directories. You do not want this at all! Everything you want to do (for Qt) you need to use python3 as the command interpreter, for Python 3!!

                    Oak77O 1 Reply Last reply
                    1
                    • JonBJ JonB

                      @Oak77 said in libQt5Core5 missmatch (beginner):

                      python -m site

                      Before you go any further! Under Linux python executes Python 2. That's why you're seeing all those python2.7 directories. You do not want this at all! Everything you want to do (for Qt) you need to use python3 as the command interpreter, for Python 3!!

                      Oak77O Offline
                      Oak77O Offline
                      Oak77
                      wrote on last edited by
                      #12

                      @JonB You're spot on, but I didn't think it was a problem. Running

                      > python
                      Python 2.7.17 (default, Jan 24 2020, 15:33:58) [GCC] on linux2
                      Type "help", "copyright", "credits" or "license" for more information.
                      >>> 
                      

                      ...as oposed to:

                      > python3
                      Python 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC] on linux
                      Type "help", "copyright", "credits" or "license" for more information.
                      >>> 
                      

                      So in terminal, it seems to really run pyuic from 2.7, not 3.6.

                      By this time I am totally confused how to make Pythons consistent while maintaining existing dependencies in the OS.

                      QtCreator is set to 3.6.10 (Tools --> Options: Python: Interpreters: Make default 3.6.10) as mentioned at the beginnig and the project to run in the same environment (Interpreter = Python 3.6.10).

                      What else I can do to get things working?

                      I asume that Python 2.7.17 is sitting there due to dependencies of intalled applications.

                      jazzycamelJ 1 Reply Last reply
                      0
                      • Oak77O Oak77

                        @JonB You're spot on, but I didn't think it was a problem. Running

                        > python
                        Python 2.7.17 (default, Jan 24 2020, 15:33:58) [GCC] on linux2
                        Type "help", "copyright", "credits" or "license" for more information.
                        >>> 
                        

                        ...as oposed to:

                        > python3
                        Python 3.6.10 (default, Jan 16 2020, 09:12:04) [GCC] on linux
                        Type "help", "copyright", "credits" or "license" for more information.
                        >>> 
                        

                        So in terminal, it seems to really run pyuic from 2.7, not 3.6.

                        By this time I am totally confused how to make Pythons consistent while maintaining existing dependencies in the OS.

                        QtCreator is set to 3.6.10 (Tools --> Options: Python: Interpreters: Make default 3.6.10) as mentioned at the beginnig and the project to run in the same environment (Interpreter = Python 3.6.10).

                        What else I can do to get things working?

                        I asume that Python 2.7.17 is sitting there due to dependencies of intalled applications.

                        jazzycamelJ Offline
                        jazzycamelJ Offline
                        jazzycamel
                        wrote on last edited by
                        #13

                        @Oak77
                        If you can't find the pyuic5 command itself, but have PyQt5 installed and importable, then run pyuic as a module instead:

                        $ python3 -m PyQt5.uic.pyuic -x mainw.ui -o mainw.py
                        

                        For future reference, I always recomend using a seperate virtualenv for each python project you develop. That way you always know where the libraries/tools are and you don't get cross-contamination or version issues.

                        Hope this helps :o)

                        For the avoidance of doubt:

                        1. All my code samples (C++ or Python) are tested before posting
                        2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
                        Oak77O 1 Reply Last reply
                        1
                        • jazzycamelJ jazzycamel

                          @Oak77
                          If you can't find the pyuic5 command itself, but have PyQt5 installed and importable, then run pyuic as a module instead:

                          $ python3 -m PyQt5.uic.pyuic -x mainw.ui -o mainw.py
                          

                          For future reference, I always recomend using a seperate virtualenv for each python project you develop. That way you always know where the libraries/tools are and you don't get cross-contamination or version issues.

                          Hope this helps :o)

                          Oak77O Offline
                          Oak77O Offline
                          Oak77
                          wrote on last edited by Oak77
                          #14

                          "python3 -m PyQt5.uic.pyuic -x mainw.ui -o mainw.py"

                          @jazzycamel - That worked and once I see it, I understand why. Thank you very much.

                          I tried one project and set it with virtual environment, but it downloaded some 320 GB of data (for only some dozens of bytes long tutorial). So it can spiral out into significant gigabytes for only few kilobytes I program at the moment, while learning. It seems to me a bit unreasonagle, unless for projects with specific needs. Unless I misunderstood something, which I easily could, at this stage.
                          And I also have to get to undertand how Python is set up anyway, if I want to use it, so I'll am testing both ways.

                          jazzycamelJ 1 Reply Last reply
                          0
                          • Oak77O Oak77

                            "python3 -m PyQt5.uic.pyuic -x mainw.ui -o mainw.py"

                            @jazzycamel - That worked and once I see it, I understand why. Thank you very much.

                            I tried one project and set it with virtual environment, but it downloaded some 320 GB of data (for only some dozens of bytes long tutorial). So it can spiral out into significant gigabytes for only few kilobytes I program at the moment, while learning. It seems to me a bit unreasonagle, unless for projects with specific needs. Unless I misunderstood something, which I easily could, at this stage.
                            And I also have to get to undertand how Python is set up anyway, if I want to use it, so I'll am testing both ways.

                            jazzycamelJ Offline
                            jazzycamelJ Offline
                            jazzycamel
                            wrote on last edited by
                            #15

                            @Oak77
                            I'm not sure why it would download that much data for a virtualenv, I must have 30 or 40+ on my machine, they are basically throw away tiny things.

                            Anyways, I'm glad it worked for you :o)

                            For the avoidance of doubt:

                            1. All my code samples (C++ or Python) are tested before posting
                            2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
                            1 Reply Last reply
                            2
                            • Oak77O Offline
                              Oak77O Offline
                              Oak77
                              wrote on last edited by
                              #16

                              To close this thread, this is final working code:

                              import sys
                              from PySide2 import QtWidgets
                              from PySide2.QtUiTools import QUiLoader
                              from PySide2.QtWidgets import QApplication
                              
                              
                              class Form(QObject):
                              
                                  def __init__(self, ui_file, parent=None):
                                      super(Form, self).__init__(parent)
                                      ui_file = QFile(ui_file)
                                      ui_file.open(QFile.ReadOnly)
                                      
                                      self.window.show()
                              
                              
                              if __name__ == '__main__':
                                  app = QApplication(sys.argv)
                                  form = Form('mainwindow.ui')
                                  sys.exit(app.exec_())
                                      
                              
                              1 Reply Last reply
                              1

                              • Login

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