ITADN

chardet 7.0.0 mypyc-compiled module causes ModuleNotFoundError in frozen apps

#993Closedmaksimu 创建于 2026-03-05
good first issuepull-request-wanted
M
maksimucommented
## Summary `chardet` 7.0.0 (released 2026-03-04) ships mypyc-compiled binary wheels for Linux/macOS/Windows. The compiled module has a dynamically-generated internal name (e.g. `0deeb2fec52624e647be__mypyc`) that PyInstaller does not discover automatically, causing frozen apps that import `chardet` to fail at runtime. ## Error ``` Traceback (most recent call last): File "chardet/__init__.py", line 13, in <module> File "pyimod02_importers.py", line 457, in exec_module File "chardet/detector.py", line 14, in <module> File "pyimod02_importers.py", line 457, in exec_module File "chardet/pipeline/orchestrator.py", line 7, in <module> ModuleNotFoundError: No module named '0deeb2fec52624e647be__mypyc' [PYI-5533:ERROR] Failed to execute script due to unhandled exception! ``` ## Affected versions - `chardet >= 7.0.0` (first version to ship mypyc wheels — also introduced a new `pipeline/` subpackage with multiple mypyc-compiled `.so` files) - `chardet <= 6.0.0.post1` is unaffected (pure Python) ## Suggested fix The same pattern already used for `pytokens` (added in v2026.0) applies here: **`hook-chardet.py`** ```python from _pyinstaller_hooks_contrib.utils.mypy import find_mypyc_module_for_dist hiddenimports = find_mypyc_module_for_dist('chardet') ``` This uses the existing `find_mypyc_module_for_dist()` utility to dynamically discover the hash-prefixed mypyc module regardless of chardet version. ## References - chardet 7.0.0 release: https://pypi.org/project/chardet/7.0.0/ - Existing `pytokens` hook: `_pyinstaller_hooks_contrib/stdhooks/hook-pytokens.py` - `find_mypyc_module_for_dist` utility: `_pyinstaller_hooks_contrib/utils/mypy.py`
关闭于 2026-03-08 0 条评论