When I am trying to build an executable for my python script it gives me:
pkg_resources.DistributionNotFound: The \'google-cloud-firestore\' distribution wa
If you are not able to locate hooks-google.cloud.py
in the PyInstaller package, you can try to locate it in:
C:\Users\<USER>\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks
or if you are using a virtual environment, you can look for _pyinstaller_hooks_contrib\hooks
instead if you are using it to build the exe file.
If the error still persists, you can take a look at the build log to locate where hook-google.cloud.py
is built from.
I hope this helps somebody out in the future as it works for me.
for two days, i have found the solution with three steps
in hook-google.cloud
add this code.
datas += copy_metadata('google-cloud-firestore')
root of hook-google.cloud.py
..
C:\Users\ASPIREone\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PyInstaller\hooks
make
hook-google-cloud-firestore.py
in root of:
C:\Users\ASPIREone\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PyInstaller\hooks
and add this code
from PyInstaller.utils.hooks import copy_metadata, get_package_dir
datas += copy_metadata('google-cloud-firestore')
datas += copy_metadata('google_cloud_firestore') #altlll
hiddenimports += ['google-cloud-firestore_v1']
#pythonhosted.org/pyinstaller/hooks.html#understanding-pyinstaller-hooks
#get_package_dir returns tuple (where pkg stored, abs path to pkg)
pkg_dir = 'C:/Users/ASPIREone/AppData/Local/Programs/Python/Python37-32/Lib/site-packages/google/cloud/firestore_v1'
datas += (pkg_dir, 'google-cloud-firestore')
don't forget to delete folder __pycache__
in your main project my main project is root of C:\Users\ASPIREone\PycharmProjects\amazon\parking-go
delete your app (example: main.exe) in root of:
C:\Users\ASPIREone\AppData\Local\Programs\Python\Python37-32\Scripts\dist
go to command line
don't use pyinstaller.exe --onefile main.py
but use
pyinstaller.exe --onefile --clean main.py
because m main proect in root folder so i write in command line:
pyinstaller.exe --onefile --clean C:\Users\ASPIREone\PycharmProjects\amazon\parking-go\main.py
you have to clean it and rebuild from first
it should work !
if you have an error when your app running when retrieve data or write to firestore like this:
Exception ignored in: 'grpc._cython.cygrpc.ssl_roots_override_callback'
E0527 07:10:01.571000000 3672 src/core/lib/security/security_connector/ssl_util
s.cc:449] assertion failed: pem_root_certs != nullptr
roots.pm
into your main project or where you run your app
dir of roots.pm
is
C:\Users\ASPIREone\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\grpc\_cython\_credentials\roots.pm
hook-grpc.py
and put this codefrom PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('grpc')
go to commandline
pyinstaller.exe --onefile --clean yourmainfile.py
it should work !
Recently i found a solution for this,hope this will fix your problem too.
Create two hook files:
In hook-google.cloud.firestore.py write below code and save it somewhere:
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('google-cloud-firestore')
In hook-grpc.py write below code and save it at same place:
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files ( 'grpc' )
Now copy paste both the files to :
C:\Users\Paul\AppData\Local\Programs\Python\Python38\Lib\site-packages\PyInstaller\hooks
If you still face the problem, Please use setuptools version 45.0.0 and then run pyinstaller and create your exe file by:
pyinstaller --clean --onefile yourfilename.py