I am trying to use pyinstaller to compile a python file. I have come across this error after the file has been compiled successfully and I have opened it. line 1 of keygen.py is: Import pyrebase which is what is causing this problem.
Traceback (most recent call last):
File "Keygen.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/pyrebase/__init__.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/pyrebase/pyrebase.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/pyimod03_importers.py", line 631, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/gcloud/__init__.py", line 19, in <module>
File "site-packages/pkg_resources/__init__.py", line 564, in get_distribution
File "site-packages/pkg_resources/__init__.py", line 436, in get_provider
File "site-packages/pkg_resources/__init__.py", line 984, in require
File "site-packages/pkg_resources/__init__.py", line 870, in resolve
pkg_resources.DistributionNotFound: The 'gcloud' distribution was not found and is required by the application
[21369] Failed to execute script Keygen
Hello, is your case similar to the case here?
pyinstaller executable can't find package info #1187
I'm afraid that we cannot help with this issue: gcloud is the now-deprecated former name of this software, and is still available on PyPI. PyInstaller seems to destroy information about the installed package which other packaging tools (setuptools, pip, etc.) create / use.
no solution for this?
You will need to create a pyinstaller hook for packages that depend on setuptools' get_distribution() to obtain metadata information about the package.
Create a hook file in some hooks directory. The file name should be
hook-<modulename>.pyfor pyinstaller to find it properly (i.e.hook-gcloud.py).The content will be:
from PyInstaller.utils.hooks import copy_metadata datas = copy_metadata('gcloud')The hooks directory should be set in the Analysis phase of your pyinstaller .spec file:
a = Analysis(['bogus.py'], pathex=[], binaries=[], hiddenimports=[], hookspath="/path/to/your/hooks/dir", runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher)I haven't tested the above, but this is what worked for me for another python package which is doing something similar (APScheduler).
If and when you get this working, consider contributing the hook back to pyinstaller project.
@Rahuld753 Thank you for posting your Solution. I have been trying to solve this problem for 1 week.
You are a gods gift :100:
pkg_resources.DistributionNotFound: The 'gcloud' distribution was not found and is required by the application [21369] Failed to execute script
I solved this problem by copy pasting the missing resource gcloud from Python\Python37\Lib\site-packages to dist folder where my .exe file is saved :)
Hope this solves your problem too.
Most helpful comment