PyInstaller file fails to execute script - DistributionNotFound

亡梦爱人 提交于 2019-12-04 11:41:06

My personal solution:

  1. Change all calls to get_distribution with it returned values (0.21.0 in my case)
  2. Remove from pkg_resources import get_distribution from import

for all files in the package.

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 import copy_metadata

datas = copy_metadata('gcloud')

In my experience base on the helps in https://github.com/GoogleCloudPlatform/google-cloud-python/issues/1187 :

  1. Go \Anaconda3\Lib\site-packages\PyInstaller\hooks folder (if you use anaconda otherwise you need to find it under python folder)
  2. Find the hook-google-cloud.py (If exist, otherwise you need to creat the hook.
  3. 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!