GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Breaking change: 1.8.1 breaks PyInstaller apps and any scenario where library is not installed with pip · Issue #876 · googleapis/google-api-python-client

Breaking change: 1.8.1 breaks PyInstaller apps and any scenario where library is not installed with pip #876

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Breaking change: 1.8.1 breaks PyInstaller apps and any scenario where library is not installed with pip#876
Copy link
Assignees
busunkim96
Labels
type: processA process-related concern. May include testing, release, or the like.

Description

@jay0lee
jay0lee
opened on Apr 21, 2020
Issue body actions

Environment details

  • OS type and version: ANY
  • Python version: ANY
  • pip version: ANY (or N/A)
  • google-api-python-client version: 1.8.1

Steps to reproduce

  1. Install 1.8.1
  2. Attempt to compile Python app that uses googleapiclient to an executable

Expected results

executable compiles and runs as it did with 1.8.0 library

Actual results

executable compiles but fails at runtime with:

pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application

this is due to removing googleapiclient.version and replacing with:

https://github.com/googleapis/google-api-python-client/blob/master/googleapiclient/model.py#L36

these issues will also occur if the library was not installed via pip (e.g. just cloned into a sub directory of the script).

Reacted by Michael Weiss

Activity

Next
  1. celsooliveiraTBDE commented on Apr 21, 2020

    @celsooliveiraTBDE
    celsooliveiraTBDE
    on Apr 21, 2020
    More actions

    I get this error also when installing in pip3
    module 'googleapiclient' has no attribute '__version__'

    Reacted by Michael Weiss and marcosvcunha
  2. jay0lee commented on Apr 21, 2020

    @jay0lee
    jay0lee
    on Apr 21, 2020
    ContributorAuthor
    More actions

    I was able to work around this with following changes to my PyInstaller .spec file:

    extra_files = [copy_metadata('google-api-python-client')]
    
    a = Analysis(['gyb.py'],
                 excludes=['FixTk', 'tcl', 'tk', '_tkinter', 'tkinter', 'Tkinter'],
                 datas=extra_files,
                 hiddenimports=[],
                 hookspath=None,
                 runtime_hooks=None)
    

    the important steps being setting extra_files and then specifying it as the datas parameter to Analysis()

    I still wanted to call out that this seems to have broken a number of projects.

    Reacted by Michael Hucka and Aaron Ciuffo
  3. busunkim96 commented on Apr 21, 2020

    @busunkim96
    busunkim96
    on Apr 21, 2020
    Contributor
    More actions

    @celsooliveiraTBDE That issue no attribute __version__ will be fixed in the next release. See #870 and #871.

    We also recommend that you import from googleapiclient rather than apiclient.

    from googleapiclient import discovery

    @jay0lee We moved to declaring the version in the setup.py and using pkg_resources as that is more consistent with what our modern clients do. If you need to use pyinstaller, it looks like there is a workaround. https://stackoverflow.com/questions/34775667/pyinstaller-django-pkg-resources-distributionnotfound-the-django-omnibus

    EDIT: Switched the link to the possible solution.

  4. busunkim96 commented on Apr 21, 2020

    @busunkim96
    busunkim96
    on Apr 21, 2020
    Contributor
    More actions

    1.8.2 is now released.

    Reacted by Michael Weiss
  5. busunkim96
    closed this as completedon Apr 21, 2020
  6. SeanCodeMedia commented on May 6, 2020

    @SeanCodeMedia
    SeanCodeMedia
    on May 6, 2020
    More actions

    Hey guys, I had the same issue with pyinstaller what did the trick for me was to roll back from
    google-api-python-client from version 1.8.2 to 1.8.0. I hope this issue gets fixed soon. It wasn't fixed in 1.8.2 as commented due to the fact I was facing the same issue on 1.8.2

    python -m pip install google-api-python-client==1.8.0

    Thanks

    Reacted by Eric Liu, Mark Rudenko, mamrouche, Jie Jenn, Sean Peart , Akash Manna, Mustafa, Aditya Aravind, Taras Denysenko, eito-pi and 12 more
    Reacted by Akash Manna
    Reacted by heweton, Sean Peart , Akash Manna, Aditya Aravind, Taras Denysenko, BernardinD and Parinav
    Reacted by Akash Manna, Aditya Aravind, Taras Denysenko, borissliz, Oobx and Farrukh Razikov
    Reacted by Mark Rudenko, Sean Peart , Akash Manna and Aditya Aravind
  7. busunkim96 commented on May 6, 2020

    @busunkim96
    busunkim96
    on May 6, 2020
    Contributor
    More actions

    @BoxingStudioGames What error are you seeing?

  8. SeanCodeMedia commented on May 8, 2020

    @SeanCodeMedia
    SeanCodeMedia
    on May 8, 2020
    More actions

    Here is the error I was getting
    pkg_resources.DistributionNotFound: The 'google-api-python-client' distribution was not found and is required by the application manage returned -1
    I was able to bypass this error by downgrading the library as commented in my last post.

  9. jay0lee commented on May 8, 2020

    @jay0lee
    jay0lee
    on May 8, 2020
    ContributorAuthor
    More actions

    Sean, I was able to get things working with the latest library by modifying my PyInstaller spec file to include the package metadata, see:

    https://github.com/jay0lee/GAM/blob/master/src/gam.spec#L16

    Reacted by Michael Hucka
  10. SeanCodeMedia commented on May 8, 2020

    @SeanCodeMedia
    SeanCodeMedia
    on May 8, 2020
    More actions

    Hi Jay, I am going to give your solution a try with the version.
    Thanks

  11. awoods3d commented on May 18, 2020

    @awoods3d
    awoods3d
    on May 18, 2020
    More actions

    Thanks jay0lee. The extended code segment from the .spec file described in https://github.com/jay0lee/GAM/blob/master/src/gam.spec#L16 solved this problem for me. Thanks!!!

  12. DataSolveProblems commented on Jun 19, 2020

    @DataSolveProblems
    DataSolveProblems
    on Jun 19, 2020
    More actions

    Roll back to google-api-python-client 1.8.0 worked for me. Thanks BoxingStudioGames. Wasted a good 3 hours fixing this issue this morning.... with the latest version google-api-python-client.

    Reacted by Sean Peart and Dalnec
    Reacted by Ash Berlin-Taylor
  13. jay0lee commented on Sep 14, 2020

    @jay0lee
    jay0lee
    on Sep 14, 2020
    ContributorAuthor
    More actions

    @DrMantisTobbogan yes, it still works for me with latest versions.

    Reacted by Sean Peart
  14. mhucka commented on Sep 24, 2020

    @mhucka
    mhucka
    on Sep 24, 2020
    More actions

    I realize this issue is closed, but in case anyone else is still encountering the error with more recent versions of google-api-python-client, I can report that you can get the error even with google-api-python-client version 1.12.2, at least when using PyInstaller 3.5 on a Windows 10 system in Python 3.6. The solution posted by @jay0lee upthread (#876 (comment)), namely to use copy_metadata, solved the problem for me. (And I must say, the error and situation are extremely confusing. I don't know how I would have arrived at that solution myself. I spent at least 2–3 hours doing down a different rabbit hole of things like hidden imports, PyInstaller hooks, etc. I'm extremely thankful for @jay0lee's work on this.)

  15. 9 remaining items

  16. busunkim96
    added
    type: processA process-related concern. May include testing, release, or the like.
    on Oct 15, 2020
  17. busunkim96
    self-assigned this
    on Oct 15, 2020
  18. meridorkobi commented on Nov 1, 2020

    @meridorkobi
    meridorkobi
    on Nov 1, 2020
    More actions

    i had the same problem
    after
    from PyInstaller.utils.hooks import copy_metadata
    extra_files = copy_metadata('google-api-python-client')
    extra_files.append(('./resource_1', './resource_1'))
    i have

    PyInstaller cannot check for assembly dependencies.
    Please install pywin32-ctypes.

    pip install pywin32-ctypes

    what can i do?

  19. acibiber53 commented on Nov 30, 2020

    @acibiber53
    acibiber53
    on Nov 30, 2020
    More actions

    I had this issue with python 3.7 and google-api-python-client 1.12.8.
    To solve it I added google-api-python-client as data at the initial pyinstaller line. --add-data has two parameters, SRC;DEST (for Windows), but SRC path searches from the main python scripts folder. So I just got back from my initial directory, then wrote the right path. So it looked like this:

    --add-data ../../../../anaconda3/envs/[ENVIRONMENT_NAME]/lib/site-packages/google_api_python_client-1.12.8.dist-info;google_api_python_client-1.12.8.dist-info

    Writing the whole path for SRC like "C://.../././" didn't work.

    As DEST path, I tried to write a dot, but it didn't work.

    One last issue I had before solving was quotes. In the Adding Data Files explanation of PyInstaller, it shows that you need to add quotes. It turns out that when looking for that path, PyInstaller actually shows these quotes as the part of path, so it can't find them (at least it was showing it that way in the spec file). So no need to write the quotes.

    2021 August Edit: I think now the part about quotes has been changed. Now you need to add them.

    Reacted by Dmitriy-Andreyev and vpsv6
  20. LMaiorano commented on Jun 29, 2022

    @LMaiorano
    LMaiorano
    on Jun 29, 2022
    More actions

    Still seeing this issue in 2022 using:

    • Python 3.9
    • google-api-python-client==2.42.0

    However, I found a fix. I simply needed to set the static_discovery argument to FALSE in the build() function.
    Eg:
    service = build('drive', 'v3', credentials=creds, static_discovery=False)

    Nothing else needed to be changed in the spec file. I hope this helps others as well!

  21. Mte90 commented on Jun 29, 2022

    @Mte90
    Mte90
    on Jun 29, 2022
    More actions

    Do you mean in the latest version of the package? It is a patch to this library?

  22. LMaiorano commented on Jun 29, 2022

    @LMaiorano
    LMaiorano
    on Jun 29, 2022
    More actions

    Do you mean in the latest version of the package? It is a patch to this library?

    Not sure if it's a specific patch to this library to address this issue, but it works now. Wanted to share this in case others were still struggling

  23. jay0lee commented on Jun 29, 2022

    @jay0lee
    jay0lee
    on Jun 29, 2022
    ContributorAuthor
    More actions

    @LMaiorano that's actually a different issue. Since version 2.0.0 this library has included static documents for all Google Discovery APIs. To use them, you'd need to tell PyInstaller to include those static .json files in your build.

    #1109

    https://pyinstaller.org/en/stable/spec-files.html#adding-files-to-the-bundle

    or, as you found you can just set static_discovery=False which causes the library to dynamically download the API's discovery file from Google on build().

    Reacted by Luigi Maiorano
  24. mtsanovv
    added a commit that references this issue on Aug 22, 2022

    Fix YouTube API connection failure

    80ce2e8
  25. natelwhite commented on Jan 26, 2023

    @natelwhite
    natelwhite
    on Jan 26, 2023
    More actions

    I've got the same issue. Tried @LMaiorano solution and got this traceback from the executable
    File "googleapiclient_helpers.py", line 130, in positional_wrapper
    File "googleapiclient\discovery.py", line 287, in build
    File "googleapiclient\discovery.py", line 422, in retrieve_discovery_doc
    File "googleapiclient_helpers.py", line 130, in positional_wrapper
    File "googleapiclient\http.py", line 923, in execute
    File "googleapiclient\http.py", line 191, in retry_request
    File "httplib2_init
    .py", line 1577, in request
    File "httplib2_init
    .py", line 1096, in init
    File "httplib2_init_.py", line 179, in _build_ssl_context
    FileNotFoundError: [Errno 2] No such file or directory

    There's nothing exceptionally odd about the feedback from pyinstaller. Other than a Traceback when it got a TypeError because it got a WindowsPath instead of string, bytes, or os.PathLike object, it's pretty normal.
    On the other hand, the warnings.txt file is a mess. It has over 100 lines worth of missing modules.

  26. siddharth71334 commented on Jun 5, 2023

    @siddharth71334
    siddharth71334
    on Jun 5, 2023
    More actions

    Still seeing this issue in 2022 using:

    • Python 3.9
    • google-api-python-client==2.42.0

    However, I found a fix. I simply needed to set the static_discovery argument to FALSE in the build() function. Eg: service = build('drive', 'v3', credentials=creds, static_discovery=False)

    Nothing else needed to be changed in the spec file. I hope this helps others as well!

    thanks so much this trick works for me

  27. ArthurKlausHoff commented on Jun 12, 2023

    @ArthurKlausHoff
    ArthurKlausHoff
    on Jun 12, 2023
    More actions

    Some info about this issue

    Pyinstaller have a hook that should include files needed by the API client.

    But this hook is failing to include the static discovery files: WARNING: collect_data_files - skipping data collection for module 'googleapiclient.discovery' as it is not a package.

    But modifying the hook, from

    collect_data_files('googleapiclient.discovery', excludes=['*.txt', '**/__pycache__'])

    to

    collect_data_files('googleapiclient.discovery_cache', excludes=['*.txt', '**/__pycache__'])

    Seems to fix it, the warning above doesn't appear and i can use the generated executable without manually modifying the .spec or using static_discovery=False.

    Anyone can test it by including this in .spec:

    from PyInstaller.utils.hooks import collect_data_files
    
    datas = collect_data_files('googleapiclient.discovery_cache', excludes=['*.txt', '**/__pycache__'])
  28. bwoodsend
    added a commit that references this issue on Jun 12, 2023

    hooks: Fix googleapiclient.model missing docs and improve test (#596)

    b8c741d
  29. daniel-sanche commented on May 28, 2026

    @daniel-sanche
    daniel-sanche
    on May 28, 2026
    Contributor
    More actions

    This issue is being bulk closed due to inactivity. Please re-open if you think this still requires attention, and we'll take another look. Thanks!

  30. daniel-sanche
    closed this as not plannedon May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @busunkim96
    busunkim96

Labels

type: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.