【问题标题】:Got errors, while running exe file built with pyinstaller and Google Cloud API integration in python在 python 中运行使用 pyinstaller 和 Google Cloud API 集成构建的 exe 文件时出现错误
【发布时间】:2018-05-10 23:30:02
【问题描述】:

我正在处理一个文件 python 项目。

我为实时语音流和识别集成了 google-cloud-API。

它适用于python aaa.py 命令。

现在我需要windows构建文件(.exe),所以我使用了pyinstaller程序,我成功获得了aaa.exe文件。

但我在使用 Google 云 API 运行语音流时遇到此错误。

[Errno 2] 没有这样的文件或目录: 'D:\AI\ai\dist\AAA\google\cloud\gapic\speech\v1\speech_client_config.json'

所以我将这个speech_client_config.json 文件复制到所需的路径中,之后我再次遇到以下错误。

“grpc._cython.cygrpc.ssl_roots_override_callback”中的异常 忽略 E0511 01:13:14.320000000 3108 src/core/lib/security/security_connector/security_connector.cc:1170] 断言失败:pem_root_certs != nullptr

然后,我找不到使用 google-cloud API 获得工作版本的解决方案。

我使用的是 python 版本 2.7.14

我需要你的友好帮助。

谢谢。

【问题讨论】:

  • 这在我看来像是 SSL 凭证错误。我认为您不被允许参加 GC。检查这个 code snippet 和这个 documentation 。如果这能解决您的问题,请更新。

标签: python python-2.7 google-cloud-platform pyinstaller


【解决方案1】:

我遇到了同样的问题。如果您愿意将roots.pem 与您的可执行文件一起分发(只需搜索该文件-它应该深埋在grpcio 的安装目录中),我很幸运通过将GRPC_DEFAULT_SSL_ROOTS_FILE_PATH 环境变量设置为此根的完整路径来解决此问题。 pem 文件。

【讨论】:

    【解决方案2】:

    这在我看来像是 SSL 凭据错误。我认为您不被允许参加 GC。检查这个code snippet和这个documentation

    【讨论】:

      【解决方案3】:

      2021 年更新

      致遇到此问题的任何人。多亏了这些了不起的人,我才得以成功。请参阅有关此 github 问题的完整对话。 这是link

      第 1 步

      感谢 @cbenhagen 和 @rising-stark 在这个 github 上 link

      一个名为 hook-grpc.py 的 PyInstaller 钩子看起来像这样可以解决问题:

      使用此代码创建一个名为 hook-grpc.py 的 python 文件。

      from PyInstaller.utils.hooks import collect_data_files
      datas = collect_data_files('grpc')
      

      第 2 步

      hook-grpc.py 文件放在您正在运行的python 环境的\site-packages\PyInstaller\hooks 目录中。所以基本上你可以在

      找到它

      C:\Users\yourusername\AppData\Local\Programs\Python\Python37\Lib\site-packages\PyInstaller\hooks

      注意:

      1. 只需将 yourusernamePython37 更改为您的 您正在使用的相应用户名和 python 版本。

      2. Anaconda 用户可能会有所不同。检查这个site 找到你正在使用的anaconda python环境路径。

      第三步

      完成后,您现在可以使用pyinstaller 将您的.py python 程序转换为.exe,它应该可以工作。

      【讨论】:

        猜你喜欢
        • 2018-10-07
        • 1970-01-01
        • 2020-12-25
        • 1970-01-01
        • 2021-04-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-11-17
        相关资源
        最近更新 更多