Pyinstaller File Fails To Execute Script - Distributionnotfound
Solution 1:
It is basically package building name issue. Pyinstaller tries to import
google.cloud
where Google cloud package is now called
gcloud
. So you need to create a hook file for that names
C:\Users\\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\PyInstaller\hooks\hook-gcloud.py
File contents:
from PyInstaller.utils.hooks importcopy_metadatadatas= copy_metadata('gcloud')
Solution 2:
Alternate hook tweak
I'm running into this same essential problem with the Google speech engine.
It's odd how everyone here seems to have success with slightly alternate solutions to this. I really don't understand how the "patches" to the hook which leave copy_metadata('google-cloud-core')
in place can work? The error thrown back reads The 'google-cloud-core' distribution was not found...
, so how can one execute that line as is?
This is my replacement for the file content of hook-google.cloud.py, in order to build an exe using google speech:
# PATCH: PROVIDED ALTERNATE PACKAGE NAMEfrom PyInstaller.utils.hooks import copy_metadata
try: datas = copy_metadata('google-cloud-core')
except: datas = copy_metadata('google-cloud-speech')
Solution 3:
In my experience base on the helps in https://github.com/GoogleCloudPlatform/google-cloud-python/issues/1187 :
- Go \Anaconda3\Lib\site-packages\PyInstaller\hooks folder (if you use anaconda otherwise you need to find it under python folder)
- Find the hook-google-cloud.py (If exist, otherwise you need to creat the hook.
- Write to existing code as shown below
''' Copyright (c) 2017, PyInstaller Development Team. Distributed under the terms of the GNU General Public License with exception for distributing bootloader. The full license is in the file COPYING.txt, distributed with this software. '''from PyInstaller.utils.hooks import copy_metadata datas = copy_metadata('google-cloud-core') datas += copy_metadata('google-cloud-translate') datas += copy_metadata('google-api-core')
Hope you find this explaination helpful. Thank you.
Solution 4:
My personal solution:
- Change all calls to get_distribution with it returned values (0.21.0 in my case)
- Remove
from pkg_resources import get_distribution
from import
for all files in the package.
Solution 5:
I had the exact same issue. I solved it by doing this:
- Goto the Pyinstaller hooks folder (~\Lib\site-packages\PyInstaller\hooks)
- Find the file hook-google.cloud.py, open it, and add the following code to it
datas += copy_metadata('google-cloud-translate')
datas += copy_metadata('google-api-core')
The issue seems to be that get_distribution is not working with the default google.cloud.translate hook, so I just added this to a hook that was working.
Hope this helps someone.
Post a Comment for "Pyinstaller File Fails To Execute Script - Distributionnotfound"