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

pyside6-deploy errors because "a lot of QML files are included" even when QML not used, or because "cannot access local variable 'tree'"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.7.3
    • 6.7.1
    • PySide, Tooling
    • None
    • Linux/Wayland

    Description

      I am finding it impossible to even get pyside6-deploy to run.

      My project uses primarily PySide6.QtCore and QtWidgets, plus QDesktopServices, QColor, QPainter, QPaintEvent from PySide6.QtGui. Everything is written in Python, no C++ or QML at all.

      When I try to run `pyside6-deploy` the following happens:

      >>> pyside6-deploy ./mo.py --verbose
      INFO:root:[DEPLOY] Start
      INFO:root:[DEPLOY] Using Python at /home/matterhorn103/python/mo/.venv/bin/python3
      INFO:root:[DEPLOY] Using existing config file /home/matterhorn103/python/mo/pysidedeploy.spec
      INFO:root:[DEPLOY] No .pyproject file found. Project file not set
      Traceback (most recent call last):
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy.py", line 187, in <module>
          main(args.main_file, args.name, args.config_file, args.init, args.loglevel, args.dry_run,
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy.py", line 92, in main
          config = DesktopConfig(config_file=config_file, source_file=main_file, python_exe=python.exe,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/config.py", line 380, in __init__
          super().__init__(config_file, source_file, python_exe, dry_run, existing_config_file,
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/config.py", line 130, in __init__
          self._find_and_set_qml_files()
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/config.py", line 276, in _find_and_set_qml_files
          raise RuntimeError(
      RuntimeError: You are including a lot of QML files from a local virtual env. This can lead to errors in deployment.
      

      If I only install `pyside6-essentials` and not `pyside6` (which installs both `pyside6-essentials` and `pyside6-addons`), the error is instead:

      pyside6-deploy ./mora_the_explorer.py --verbose
      INFO:root:[DEPLOY] Start
      INFO:root:[DEPLOY] Using Python at /home/matterhorn103/python/mo/.venv/bin/python3
      INFO:root:[DEPLOY] Using existing config file /home/matterhorn103/python/mo/pysidedeploy.spec
      INFO:root:[DEPLOY] No .pyproject file found. Project file not set
      INFO:root:[DEPLOY] QML files identified and set in config_file
      [DEPLOY] Unable to parse /home/matterhorn103/python/mo/mora_the_explorer/__init__.py
      Traceback (most recent call last):
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/dependency_util.py", line 141, in pyside_module_imports
          tree = get_ast(py_file)
                 ^^^^^^^^^^^^^^^^
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/dependency_util.py", line 78, in get_ast
          return tree
                 ^^^^
      UnboundLocalError: cannot access local variable 'tree' where it is not associated with a value
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy.py", line 187, in <module>
          main(args.main_file, args.name, args.config_file, args.init, args.loglevel, args.dry_run,
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy.py", line 92, in main
          config = DesktopConfig(config_file=config_file, source_file=main_file, python_exe=python.exe,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/config.py", line 386, in __init__
          self._find_and_set_pysidemodules()
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/config.py", line 352, in _find_and_set_pysidemodules
          self.modules = find_pyside_modules(project_dir=self.project_dir,
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/dependency_util.py", line 176, in find_pyside_modules
          all_modules = all_modules.union(pyside_module_imports(py_candidate))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/matterhorn103/python/mo/.venv/lib/python3.12/site-packages/PySide6/scripts/deploy_lib/dependency_util.py", line 169, in pyside_module_imports
          raise RuntimeError(f"[DEPLOY] Finding module import failed on file {str(py_file)} with "
      RuntimeError: [DEPLOY] Finding module import failed on file /home/matterhorn103/python/mo/mo/__init__.py with error cannot access local variable 'tree' where it is not associated with a value
      

      Following the indication at https://doc.qt.io/qtforpython-6/deployment/deployment-pyside6-deploy.html that the venv used shouldn't be located in the directory, I tried removing it and using a venv located somewhere else, but the result was identical. Whether I run with the `--init` flag first also seems to be irrelevant.

      Attachments

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

        Activity

          People

            shpremna Shyamnath Premnadh
            matterhorn103 Matthew Milner
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes