Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1621

Windows: Unable to load shiboken2 after freezing on share directory

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4: Low
    • Resolution: Done
    • Affects Version/s: 5.15.2
    • Fix Version/s: 6.1.3, 5.15.6
    • Component/s: Shiboken
    • Labels:
      None
    • Platform/s:
      Windows
    • Commits:
      f7db16f3e9e7a567a3f8993507b701b20addb627 (pyside/pyside-setup/dev) 3fe4c74f3e57b89c7891f27ccc4568ac30bab699 (pyside/pyside-setup/6.1) 1f4c770c07b64d33e0f5a73dd82a0e25ac23c7f3 (pyside/tqtc-pyside-setup/tqtc/5.15)

      Description

      Hello team,

      I have an issue when I freeze my PySide2 application.
      I am unable to launch it on a shared directory.
      This issue is related to issues:

      Platform configuration:

      • Windows 10 x86_64
      • Python 3.9.6
      • Virtual Env:
        • cx_Freeze 6.7
        • PySide2 5.15.2

      Here the source code of my example application:

      import os
      import sys
      if getattr(sys, 'frozen', False):
          dll_path = os.path.join(os.path.dirname(sys.executable), 'lib')
          print(dll_path)
          os.add_dll_directory(dll_path)
      
      from PySide2 import QtGui, QtCore, QtUiTools, QtWidgets, QtXml
      
      print("Import OK")
      

      Here the setup.py script:

      import os
      import sys
      
      import PySide2
      from cx_Freeze import setup, Executable
      
      plugins_path = os.path.join(PySide2.__path__[0], "plugins")
      
      
      base = None
      if sys.platform == 'win32':
          base = 'Win32GUI'
      
      options = {
          'build_exe': {
              "include_files": [os.path.join(plugins_path, "platforms")],  # additional plugins needed by qt at runtime
              "zip_include_packages": ["PySide2", "shiboken2", "encodings"],  # reduce size of packages that are used
              "excludes": ["tkinter", "unittest", "email", "http", "xml", "pydoc", "pdb"],  # exclude packages that are not really needed
          }
      }
      
      executables = [
          Executable('test-gui.py', base='Console')
      ]
      
      setup(
          name='simple_PySide2',
          version='0.1',
          description='Sample cx_Freeze PySide2 script',
          options=options,
          executables=executables
      )
      

      To finish the command line that I use to freeze my application

      python setup.py build --build-exe bin\windows
      

      I specify that this application is built in a virtual environment locally.

      This application works in the following cases:

      • locally:
        • The frozen application: bin\windows\test-gui.exe
        • The application from source: python test-gui.py
      • on shared directory:
        • The application from source: python test-gui.py

      However, the freeze app crashes indefinitely when launched on a shared directory.
      After launching a ctrl-c, below the Python traces

      Traceback (most recent call last):
        File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python39\lib\genericpath.py", line 19, in exists
          os.stat(path)
      FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable: '\\\\filer001\\HOME25\\files.dir\\shibokensupport\\signature\\loader.py'
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "(builtin)", line 113, in bootstrap
        File "C:\Users\xxxxxx\AppData\Local\Programs\Python\Python39\lib\genericpath.py", line 19, in exists
          os.stat(path)
      KeyboardInterrupt
      Fatal Python error: could not initialize part 2
      Python runtime state: initialized
      
      Current thread 0x00003f08 (most recent call first):
        File "C:\temp\PYTHON39_QT5\python_env\lib\site-packages\shiboken2\__init__.py", line 30 in <module>
        File "<frozen zipimport>", line 259 in load_module
        File "<frozen importlib._bootstrap>", line 627 in _load_backward_compatible
        File "<frozen importlib._bootstrap>", line 664 in _load_unlocked
        File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
        File "C:\temp\PYTHON39_QT5\python_env\lib\site-packages\PySide2\__init__.py", line 58 in _setupQtDirectories
        File "C:\temp\PYTHON39_QT5\python_env\lib\site-packages\PySide2\__init__.py", line 107 in <module>
        File "<frozen zipimport>", line 259 in load_module
        File "<frozen importlib._bootstrap>", line 627 in _load_backward_compatible
        File "<frozen importlib._bootstrap>", line 664 in _load_unlocked
        File "<frozen importlib._bootstrap>", line 986 in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 1007 in _find_and_load
        File "test-gui.py", line 8 in <module>
        File "C:\temp\PYTHON39_QT5\python_env\lib\site-packages\cx_Freeze\initscripts\Console.py", line 15 in run
        File "C:\temp\PYTHON39_QT5\python_env\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 104 in run
      
      L:\dev\PYTHON39_QT5>
      L:\dev\PYTHON39_QT5>python PySide2app.py
      Traceback (most recent call last):
        File "L:\dev\PYTHON39_QT5\PySide2app.py", line 5, in <module>
          from PySide2.QtWidgets import QApplication, QWidget
      ModuleNotFoundError: No module named 'PySide2'
      

       

      For information, the \\filer001\HOME25 (L:) folder is the shared directory on which I launched the application.
      The application is built in the C:\temp\PYTHON39_QT5 directory

      Thanks for your help.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            ctismer Christian Tismer
            Reporter:
            lois Louis-Andréa SALBAN
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes