Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Generate binary file with pyinstaller
Forum Update on Monday, May 27th 2025

Generate binary file with pyinstaller

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 2 Posters 974 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.
  • X Offline
    X Offline
    Xav12358
    wrote on 29 Aug 2023, 11:53 last edited by
    #1

    Hello,

    I try to generate a binary file with pyinstaller. I have a program using PySide2.
    I generate my binary with

    pyinstaller  --onefile main.py -y
    

    When I run the generated binary file, I get that error:

    Traceback (most recent call last):
      File "main.py", line 4, in <module>
        from PySide2.QtWidgets import QApplication, QMainWindow
    ImportError: /tmp/_MEIA5cWN3/libQt5Widgets.so.5: undefined symbol: _ZN9QFileInfo4statEv, version Qt_5
    [67652] Failed to execute script 'main' due to unhandled exception!
    
    1 Reply Last reply
    0
    • S SGaist
      1 Sept 2023, 18:10

      Can you try with conda ? If memory serves well, they should pull the same Qt version in.

      X Offline
      X Offline
      Xav12358
      wrote on 4 Sept 2023, 10:04 last edited by
      #12

      @SGaist I have the same trouble.

      According to that documentation, pyinstaller use the system environment to build the binary file:
      https://doc.qt.io/qtforpython-5/deployment-pyinstaller.html

      So if I use Conda, Virtual Env, it will alway use the systm environment to generate the binary.

      S 1 Reply Last reply 4 Sept 2023, 17:29
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 29 Aug 2023, 18:44 last edited by
        #2

        Hi,

        How did you install PySide2 ?
        Are you sure pyinstaller is using the correct Qt version to create the package ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        X 1 Reply Last reply 29 Aug 2023, 19:17
        0
        • S SGaist
          29 Aug 2023, 18:44

          Hi,

          How did you install PySide2 ?
          Are you sure pyinstaller is using the correct Qt version to create the package ?

          X Offline
          X Offline
          Xav12358
          wrote on 29 Aug 2023, 19:17 last edited by
          #3

          @SGaist I use pip to install Pyside2.

          How could I specify the version of Qt on pyinstaller?

          The command I used is the one in the first post.

          S 1 Reply Last reply 29 Aug 2023, 19:43
          0
          • X Xav12358
            29 Aug 2023, 19:17

            @SGaist I use pip to install Pyside2.

            How could I specify the version of Qt on pyinstaller?

            The command I used is the one in the first post.

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 29 Aug 2023, 19:43 last edited by
            #4

            Did you create a virtual environment ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            X 1 Reply Last reply 29 Aug 2023, 20:06
            0
            • S SGaist
              29 Aug 2023, 19:43

              Did you create a virtual environment ?

              X Offline
              X Offline
              Xav12358
              wrote on 29 Aug 2023, 20:06 last edited by
              #5

              @SGaist no I use my system environment

              S 1 Reply Last reply 30 Aug 2023, 19:18
              0
              • X Xav12358
                29 Aug 2023, 20:06

                @SGaist no I use my system environment

                S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 30 Aug 2023, 19:18 last edited by
                #6

                I would rather do that in a dedicated environment to keep everything cleanly separated.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                X 1 Reply Last reply 31 Aug 2023, 08:24
                0
                • S SGaist
                  30 Aug 2023, 19:18

                  I would rather do that in a dedicated environment to keep everything cleanly separated.

                  X Offline
                  X Offline
                  Xav12358
                  wrote on 31 Aug 2023, 08:24 last edited by Xav12358
                  #7

                  @SGaist I generate a virtuel environment

                  I still use that command to generate the installer:

                  pyinstaller  --onefile main.py -y
                  

                  I get that error when I run ./dist/main

                  Traceback (most recent call last):
                    File "main.py", line 4, in <module>
                      from PySide2.QtWidgets import QApplication, QMainWindow
                  ImportError: could not import module 'PySide2.QtGui'
                  [154703] Failed to execute script 'main' due to unhandled exception!
                  
                  1 Reply Last reply
                  0
                  • X Offline
                    X Offline
                    Xav12358
                    wrote on 31 Aug 2023, 15:33 last edited by
                    #8

                    In fact, I think I find the trouble. I include matplotlib and Pyside2

                    One is Using Qt5.15.0 and the other Qt5.15.2.

                    How can I manage to use Matplotlib and PySide2 with the same Qt library version?

                    How can I know with Qt version matplotlib use and also Pyside. I would like to specify the version of both library to avoid the trouble

                    S 1 Reply Last reply 31 Aug 2023, 18:13
                    0
                    • X Xav12358
                      31 Aug 2023, 15:33

                      In fact, I think I find the trouble. I include matplotlib and Pyside2

                      One is Using Qt5.15.0 and the other Qt5.15.2.

                      How can I manage to use Matplotlib and PySide2 with the same Qt library version?

                      How can I know with Qt version matplotlib use and also Pyside. I would like to specify the version of both library to avoid the trouble

                      S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 31 Aug 2023, 18:13 last edited by
                      #9

                      How did you install matplotlib ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      X 1 Reply Last reply 1 Sept 2023, 05:00
                      0
                      • S SGaist
                        31 Aug 2023, 18:13

                        How did you install matplotlib ?

                        X Offline
                        X Offline
                        Xav12358
                        wrote on 1 Sept 2023, 05:00 last edited by
                        #10

                        @SGaist I also use pip

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 1 Sept 2023, 18:10 last edited by
                          #11

                          Can you try with conda ? If memory serves well, they should pull the same Qt version in.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          X 1 Reply Last reply 4 Sept 2023, 10:04
                          0
                          • S SGaist
                            1 Sept 2023, 18:10

                            Can you try with conda ? If memory serves well, they should pull the same Qt version in.

                            X Offline
                            X Offline
                            Xav12358
                            wrote on 4 Sept 2023, 10:04 last edited by
                            #12

                            @SGaist I have the same trouble.

                            According to that documentation, pyinstaller use the system environment to build the binary file:
                            https://doc.qt.io/qtforpython-5/deployment-pyinstaller.html

                            So if I use Conda, Virtual Env, it will alway use the systm environment to generate the binary.

                            S 1 Reply Last reply 4 Sept 2023, 17:29
                            0
                            • X Xav12358
                              4 Sept 2023, 10:04

                              @SGaist I have the same trouble.

                              According to that documentation, pyinstaller use the system environment to build the binary file:
                              https://doc.qt.io/qtforpython-5/deployment-pyinstaller.html

                              So if I use Conda, Virtual Env, it will alway use the systm environment to generate the binary.

                              S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 4 Sept 2023, 17:29 last edited by
                              #13

                              Then clean your system Python and work exclusively from the virtual environment.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              X 1 Reply Last reply 6 Sept 2023, 06:59
                              0
                              • S SGaist
                                4 Sept 2023, 17:29

                                Then clean your system Python and work exclusively from the virtual environment.

                                X Offline
                                X Offline
                                Xav12358
                                wrote on 6 Sept 2023, 06:59 last edited by
                                #14

                                @SGaist I clean it and I looked at the python package version. I notice that the PySide version installed was the 5.15.2 and the matplot uses the 5.15.0. I modify the PySide versin and now the package are compatible.

                                1 Reply Last reply
                                0
                                • X Xav12358 has marked this topic as solved on 6 Sept 2023, 06:59

                                1/14

                                29 Aug 2023, 11:53

                                • Login

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