I am encountering a ModuleNotFoundError when running an executable created with PyInstaller that includes the bitstring library (version 4.4.0). The script runs fine in a normal Python environment but fails once bundled.
Observed Behavior
When running the bundled .exe, the application crashes with the following traceback:
File "bitstring\__init__.py", line 75, in <module>
File "importlib\__init__.py", line 126, in import_module
ModuleNotFoundError: No module named 'bitstring.bitstore_bitarray'
Suspected Cause (Hypothesis):
Upon investigating bitstring/__init__.py, I noticed that submodules are loaded dynamically using importlib.import_module based on the _USE_RUST_CORE flag:
|
if _USE_RUST_CORE: |
|
bitstore = importlib.import_module('bitstring.bitstore_tibs') |
|
bitstore_helpers = importlib.import_module('bitstring.bitstore_tibs_helpers') |
|
else: |
|
bitstore = importlib.import_module('bitstring.bitstore_bitarray') |
|
bitstore_helpers = importlib.import_module('bitstring.bitstore_bitarray_helpers') |
I suspect that PyInstaller's static analysis might be failing to detect these dynamic imports, leading to the exclusion of these submodules from the final bundle.
I am encountering a ModuleNotFoundError when running an executable created with PyInstaller that includes the bitstring library (version 4.4.0). The script runs fine in a normal Python environment but fails once bundled.
Observed Behavior
When running the bundled .exe, the application crashes with the following traceback:
Suspected Cause (Hypothesis):
Upon investigating bitstring/__init__.py, I noticed that submodules are loaded dynamically using importlib.import_module based on the _USE_RUST_CORE flag:
bitstring/bitstring/__init__.py
Lines 71 to 76 in 68853eb
I suspect that PyInstaller's static analysis might be failing to detect these dynamic imports, leading to the exclusion of these submodules from the final bundle.