PyInstaller and the Rez API

79 views
Skip to first unread message

Prpleight _

unread,
Jun 5, 2023, 9:04:46 PM6/5/23
to rez-config
Hi,

I've been struggling to figure this for a couple of weeks. The only indication of anyone else running into this issue was posted here a couple of years ago, with no solution being posted.  I've got my fingers crossed that someone has found a solution since then.

When I try to run the .exe created by PyInstaller I an error during the import phase. (the line of code and error are below.)  But if I run  rez-env followed by  "python app.py"  It works.   I'm hoping someone can give me suggestions  or point me at some documentation that can help out.  

Thank you for any help you can give.

rez api   version 2.106.0 and 
PyInstaller 5.10.1   (windows python 3.7)

The error is generated on this line of code:   

import rezplugins.package_repository


Traceback (most recent call last):
  File "al_gui\app.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 352, in exec_module
  File "rezplugins\package_repository\__init__.py", line 6, in <module>
  File "rez\plugin_managers.py", line 75, in extend_path
  File "rez\utils\data_utils.py", line 249, in __get__
  File "rez\plugin_managers.py", line 320, in rezplugins_module_paths
AttributeError: 'FrozenImporter' object has no attribute 'path'
[1184] Failed to execute script 'app' due to unhandled exception!

Ian Henckel

unread,
Jun 6, 2023, 7:55:01 PM6/6/23
to rez-config
I think the key will be this statement in the PyInstaller docs:

> Some Python scripts import modules in ways that PyInstaller cannot detect: for example, by using the __import__() function with variable data, using importlib.import_module(), or manipulating the sys.path value at run time.

If I had to guess, the problem is that (unsurprisingly) Rez finds its plugins dynamically rather than by hard-coded import statements.

I would take a look at the suggestions in the PyInstaller docs for how to help PyInstaller find all the files it needs to bundle.

 - Ian

Reply all
Reply to author
Forward
0 new messages