I had to convert a program that uses Google Speech to Text into an .exe, but I was addicted to it, so I made a note.
OS Windows10 (At pipenv) Python 3.7.4 pyinstaller 3.6
*** Convert test.py to .exe. Assuming ***
pyinstaller test.py --onefile
ERROR1 First of all, when I run it normally, I get the following error
pkg_resources.DistributionNotFound: The 'google-cloud-core' distribution was not found and is required by the application
This error can be resolved by using the --additional-hooks-dir
option at startup, creating a file like the one below, and giving the path to the folder. I often see articles like this, but *** I couldn't solve it in my environment. *** ***
hook-google.cloud.py
from PyInstaller.utils.hooks import copy_metadata
try: datas = copy_metadata('google-cloud-core')
except: datas = copy_metadata('google-cloud-speech')
↓ I get this error
assert self.hook_module_name not in HOOKS_MODULE_NAMES
AssertionError
This problem was usually solved by installing google-cloud-core again. .. ..
pip install google-cloud-core
ERROR2 After installing google-cloud-core, it can be executed and .exe is also generated, but when the generated .exe is executed, the following error (or Exception?) Appears this time.
Exception ignored in: 'grpc._cython.cygrpc.ssl_roots_override_callback'
E0603 18:31:14.600000000 16632 src/core/lib/security/security_connector/ssl_utils.cc:482] assertion failed: pem_root_certs != nullptr
It seems to be around license authentication. Here, if you create a folder called hooks in the same hierarchy as test.py and create and install the following files in it,
hook-grpc.py
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('grpc')
If you rebuild with the following command, it will not appear
pyinstaller test.py --onefile --additional-hooks-dir=./hooks/
https://github.com/pyinstaller/pyinstaller/issues/3935 https://teratail.com/questions/201443 https://teratail.com/questions/118297 https://qiita.com/akitooo/items/eb82a5f335d8ca9c9faf https://stackoverflow.com/questions/54634035/my-pyinstaller-is-giving-assertion-error-when-i-execute-it https://stackoverflow.com/questions/40076795/pyinstaller-file-fails-to-execute-script-distributionnotfound https://www.bountysource.com/issues/86848733-pyinstaller-3-6-assertionerror https://github.com/googleapis/google-cloud-python/issues/5774
Recommended Posts