3

My application using google calendar API with the Google Python client library

from googleapiclient.discovery import build 

for

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

Create EXE using py installer

Versions -

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

Error

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

line 10 -

from googleapiclient.discovery import build 

The application working in pycharm and as python script in CMD I used py installer in CMD

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

in script pycharm

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

Im following questions about this but did not find the answer Thanks

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Kobi
  • 127
  • 1
  • 11
  • Does this answer your question? [The 'google-api-python-client' distribution was not found and is required by the application with pyinstaller](https://stackoverflow.com/questions/61510900/the-google-api-python-client-distribution-was-not-found-and-is-required-by-the) – Linda Lawton - DaImTo Nov 05 '20 at 15:13
  • @DaImTo I did it . Im using google_api_python_client 1.12.5 and moved it to recommended folders – Kobi Nov 05 '20 at 15:19

2 Answers2

0

The solution

  1. copy the folder-- google_api_core-1.23.0-py3.8.egg-info-- to execute directory
  2. rename folder name to ---google_api_python_client.egg-info--
Kobi
  • 127
  • 1
  • 11
-1

On Windows, Copy Google directories from your Python Application install locations Python//Lib/site-packages directory to the dist/<dot_py_file> directory created by pyinstaller.

Buddy Bob
  • 5,829
  • 1
  • 13
  • 44
K.Butler
  • 9
  • 1
  • 1