setuptools: [BUG] No module named 'pkg_resources.extern'
setuptools version
setuptools==70.0.0
Python version
3.8.10
OS
Windows 11
Additional environment information
No response
Description
I use PyInstaller and PyArmor to obfuscate my code and create an Executable out of it. On a pipeline of mine, an error started to throw today:
Traceback (most recent call last):
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 16, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "pkg_resources\__init__.py", line 77, in <module>
ModuleNotFoundError: No module named 'pkg_resources.extern'
Inside this Pipeline I run python -m pip install -U setuptools. I.e., it uses the latest version of it.
I tested it locally and it happens with version 70.0.0 but not with version 69.5.1
Expected behavior
Obfuscated Executable from PyArmor and PyInstaller is created.
How to Reproduce
- Create a virtual environment
- Install pyinstaller[encryption]==4.* and pyarmor==7.*
pip install tendo==0.2.*(just for the matter of having some import on the main.py file) (for some reason, it works with tendo>=0.3.0)- Create a test.py
import tendo.singleton def main(): print("Hello World!") if __name__ == "__main__": me = tendo.singleton.SingleInstance() main() - Run
pyarmor pack .\test.py -x "--exclude .venv" - Run the test.exe on
dist/test/
Output
python -m pip install -U setuptools
pip install -U pyarmor==7.* pyinstaller[encryption]==4.*
pyarmor pack main.py
Traceback (most recent call last):
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 158, in <module>
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 36, in _pyi_rthook
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "pkg_resources\__init__.py", line 77, in <module>
ModuleNotFoundError: No module named 'pkg_resources.extern'
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 6
- Comments: 19 (6 by maintainers)
Commits related to this issue
- fix: fix ggshield binary failing on Windows and Linux The standalone binary smoke test would fail with: ``` build-os-packages: [INFO] test: running --help Traceback (most recent call last): File "... — committed to GitGuardian/ggshield by agateau-gg 2 years ago
- pyinstaller: deal with setuptools >=70.0.0 Add `pkg_resources.extern` to the list of hidden imports. Fixed in pyinstaller >=6.7.0 https://github.com/pyinstaller/pyinstaller/issues/8554 https://gith... — committed to koordinates/kart by rcoup 2 years ago
- pyinstaller: deal with setuptools >=70.0.0 Add `pkg_resources.extern` to the list of hidden imports. Fixed in pyinstaller >=6.7.0 https://github.com/pyinstaller/pyinstaller/issues/8554 https://gith... — committed to koordinates/kart by rcoup 2 years ago
- build: fix pysinstaller config for setuptools 70 C.f. the discussion at <https://github.com/pypa/setuptools/issues/4374> — committed to caltechlibrary/foliage by mhucka 2 years ago
- hotfix: No module named 'pkg_resources.extern' https://github.com/pypa/setuptools/issues/4374 — committed to amzyang/alfred-better-dictionaries by deleted user 2 years ago
- Fix setuptools regression See https://github.com/pypa/setuptools/issues/4374 Fixes #133 — committed to SoftwareDefinedVehicle/vehicle-app-python-sdk by erikbosch 2 years ago
- Fix setuptools regression (#134) * Fix setuptools regression See https://github.com/pypa/setuptools/issues/4374 Fixes #133 Updating actions and pyinstaller — committed to eclipse-velocitas/vehicle-app-python-sdk by erikbosch 2 years ago
- Update; bump pyinstaller from 5.13.1 to 6.7.0 due to upstream setuptools issue; see https://github.com/pypa/setuptools/issues/4374 — committed to sixy6e/qax by deleted user 2 years ago
- Restricting setuptools due to https://github.com/pypa/setuptools/issues/4374 — committed to regro-cf-autotick-bot/hazelbean-feedstock by phargogh 2 years ago
Should be fixed now.
pip install -U pyinstallerthen use the--cleanflag next time you runpyinstaller.Harmut’s tolerance ran out a long time ago.
We’ll fix this on our end. Feel free to close this off as PyInstaller’s problem.
PyInstaller having to keep up with changes “like this” is indeed common. FWIW, I went and looked for an issue report against PyInstaller before I cam over here.
:]@abravalheri So, I tested somethings one more time here and adding
pkg_resources.externto PyInstaller’s Hidden Imports fixes the issue.As @altendky said, it might actually be something that PyInstaller needs to fix upon the changes on SetupTools. Although I wonder what actually changed on SetupTools that made it break on PyInstaller side
The interesting thing about that is that https://github.com/pypa/setuptools/commit/e9995828311c5e0c843622ca2be85e7f09f1ff0d went the other direction. But that commit also went and switched to
as _*imports. Anyways, this is likely trivial for Hartmut to fix once they look at the commit.I’ll file an issue over there, if nobody beats me to it.