Skip to content

ModuleNotFoundError: No module named 'bitstring.bitstore_bitarray' when using PyInstaller with bitstring 4.4.0 #362

@kimbyungnam

Description

@kimbyungnam

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions