python - Issues with pyinstaller and reportlab -
alright have python project want compile, decided use pyinstaller (first time compiling python). compiled fine when run exe returns -1. after bit of messing around figured out related reportlab.platypus.
so first instinct check see if using hooks changed anything, tried adding reportlab.pdfbase._fontdata
, reportlab.lib.utils
hooks (these hook files find related reportlab). despite effort still failed.
here output when exe run terminal:
traceback (most recent call last): file "<string>", line 12, in <module> file "<frozen importlib._bootstrap>", line 969, in _find_and_load file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 664, in _load_unlocked file "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible file "c:\users\jon\desktop\pyinstaller-3.1.1\pyinstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.__dict__) file "board_builder.py", line 5, in <module> file "<frozen importlib._bootstrap>", line 969, in _find_and_load file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 664, in _load_unlocked file "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible file "c:\users\jon\desktop\pyinstaller-3.1.1\pyinstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.__dict__) file "site-packages\reportlab\platypus\__init__.py", line 7, in <module> file "<frozen importlib._bootstrap>", line 969, in _find_and_load file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 664, in _load_unlocked file "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible file "c:\users\jon\desktop\pyinstaller-3.1.1\pyinstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.__dict__) file "site-packages\reportlab\platypus\flowables.py", line 32, in <module> file "<frozen importlib._bootstrap>", line 969, in _find_and_load file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 664, in _load_unlocked file "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible file "c:\users\jon\desktop\pyinstaller-3.1.1\pyinstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.__dict__) file "site-packages\reportlab\lib\styles.py", line 28, in <module> file "<frozen importlib._bootstrap>", line 969, in _find_and_load file "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked file "<frozen importlib._bootstrap>", line 664, in _load_unlocked file "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible file "c:\users\jon\desktop\pyinstaller-3.1.1\pyinstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.__dict__) file "site-packages\reportlab\rl_config.py", line 131, in <module> file "site-packages\reportlab\rl_config.py", line 102, in _startup file "site-packages\reportlab\lib\utils.py", line 695, in rl_isdir attributeerror: 'frozenimporter' object has no attribute '_files' main returned -1
from gather crashes on running line 5 in "board_builder.py" (the file handles reportlab in project) here first 5 lines of file:
import subprocess import datetime reportlab.lib.units import mm, inch reportlab.lib.pagesizes import legal, landscape reportlab.platypus import simpledoctemplate, table
i have no idea attributeerror throwing means, advice welcome!
well got working,
decided go @ attributeerror being thrown inspected reportlab/rl_config.py
, reportlab/lib/utils.py
files , found checking objects recursively looking directories (as insinuated rl_isdir
). how frozenimporter got stuck being checked list of other objects
so replaced line:
return len(list(filter(lambda x,pn=pn: x.startswith(pn),list(__loader__._files.keys()))))>0
with:
try: return len(list(filter(lambda x,pn=pn: x.startswith(pn),list(__loader__._files.keys()))))>0 except attributeerror: return false
this may not have been cleanest efficient way resolve issue touches 1 line of original code found straight forward solution.
Comments
Post a Comment