-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breaking change: 1.8.1 breaks PyInstaller apps and any scenario where library is not installed with pip #876
Comments
I get this error also when installing in pip3 |
I was able to work around this with following changes to my PyInstaller .spec file:
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. |
@celsooliveiraTBDE That issue We also recommend that you import from from googleapiclient import discovery @jay0lee We moved to declaring the version in the EDIT: Switched the link to the possible solution. |
1.8.2 is now released. |
Hey guys, I had the same issue with pyinstaller what did the trick for me was to roll back from python -m pip install google-api-python-client==1.8.0 Thanks |
@BoxingStudioGames What error are you seeing? |
Here is the error I was getting |
Sean, I was able to get things working with the latest library by modifying my PyInstaller spec file to include the package metadata, see: |
Hi Jay, I am going to give your solution a try with the version. |
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!!! |
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. |
Thanks @jay0lee, can confirm that your solution works with pyinstaller 4.0 and google-api-python-client 1.10.1! |
@DrMantisTobbogan yes, it still works for me with latest versions. |
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 |
This was a very nonobvious problem. The solution came from a GitHub issue report: googleapis/google-api-python-client#876
I see that this issue is closed, but I just ran into this issue on python 3.8.5 with google-api-python-client==1.12.3 Are there any suggestions for overcoming this? The suggested solution of using @jay0lee 's solution works, but requires importing
|
@busunkim96 can we please re-open this issue? Seems it's still a problem for many library users. |
Yes, we can adopt the strategy added recently in api-core. googleapis/python-api-core#80 |
i had the same problem PyInstaller cannot check for assembly dependencies. pip install pywin32-ctypes what can i do? |
I had this issue with python 3.7 and google-api-python-client 1.12.8.
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. |
Still seeing this issue in 2022 using:
However, I found a fix. I simply needed to set the Nothing else needed to be changed in the spec file. I hope this helps others as well! |
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 |
@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. https://pyinstaller.org/en/stable/spec-files.html#adding-files-to-the-bundle or, as you found you can just set |
Essentially, as described in googleapis/google-api-python-client#1109 and googleapis/google-api-python-client#876 - since version 2.0.0 google-api-python-client 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 or use static_discovery=False which causes the library to dynamically download the API's discovery file from Google on build(). Otherwise, pyinstaller builds will fail.
I've got the same issue. Tried @LMaiorano solution and got this traceback from the executable 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. |
thanks so much this trick works for me |
Some info about this issuePyinstaller have a hook that should include files needed by the API client. But this hook is failing to include the static discovery files: 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 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__']) |
The hook googleapiclient.model was raising this warning when running Pyinstaller: WARNING: collect_data_files - skipping data collection for module 'googleapiclient.discovery' as it is not a package. Needing workarounds to run the api client, see googleapis/google-api-python-client#876. But this can be fixed by pointing it to the correct package googleapiclient.discovery_cache. The test also received an improvement. The current test only run from googleapiclient.discovery import build which is not sufficient because the error happens when calling the build function. Calling this function doesn't require a valid API key.
Environment details
google-api-python-client
version: 1.8.1Steps to reproduce
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).
The text was updated successfully, but these errors were encountered: