【问题标题】:The 'google-api-python-client' distribution was not found on running EXE compiled by pyinstaller在运行由 pyinstaller 编译的 EXE 时找不到“google-api-python-client”分发版
【发布时间】:2021-02-18 07:13:24
【问题描述】:

我的应用程序使用谷歌日历 API 和谷歌 Python 客户端库

from googleapiclient.discovery import build 

events_result = service.events().list(calendarId='primary', timeMin=now,
                                        maxResults=100, singleEvents=True,
                                        orderBy='startTime').execute()

使用 py 安装程序创建 EXE

版本 -

72 INFO: PyInstaller: 4.1.dev0
72 INFO: Python: 3.9.0
74 INFO: Platform: Windows-10-10.0.18362-SP0
79 INFO: wrote C:\Users\PC\AppData\Local\Programs\Python\Python39\Scripts\main.spec
82 INFO: UPX is not available.
83 INFO: Extending PYTHONPATH with paths

错误

Traceback (most recent call last):
  File "main.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "googleapiclient\discovery.py", line 68, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "googleapiclient\http.py", line 67, in <module>
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "C:\Users\PC\AppData\Local\Programs\Python\Python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "googleapiclient\model.py", line 36, in <module>
  File "pkg_resources\__init__.py", line 480, in get_distribution
  File "pkg_resources\__init__.py", line 356, in get_provider
  File "pkg_resources\__init__.py", line 899, in require
  File "pkg_resources\__init__.py", line 785, in resolve
pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application
[15548] Failed to execute script main

第 10 行 -

from googleapiclient.discovery import build 

在 pycharm 和 CMD 中作为 python 脚本工作的应用程序 我在 CMD 中使用了 py 安装程序

PyInstaller -F       C:\Users\PC\PycharmProjects\.....

在脚本pycharm中

import PyInstaller.__main__
PyInstaller.__main__.run([
    'main.py',
    '--onefile',
    '--windowed'
])

我正在关注有关此的问题,但没有找到答案 谢谢

【问题讨论】:

标签: python python-3.x google-calendar-api google-api-python-client


【解决方案1】:

解决办法

  1. 复制文件夹——google_api_core-1.23.0-py3.8.egg-info——执行目录
  2. 将文件夹名称重命名为 ---google_api_python_client.egg-info--

【讨论】:

    【解决方案2】:

    在 Windows 上,将 Google 目录从 Python 应用程序安装位置 Python//Lib/site-packages 目录复制到由 pyinstaller 创建的 dist/&lt;dot_py_file&gt; 目录。

    【讨论】:

      猜你喜欢
      • 2021-05-05
      • 1970-01-01
      • 2020-11-26
      • 2020-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-07
      • 1970-01-01
      相关资源
      最近更新 更多