google-api-python-client: Breaking change: 1.8.1 breaks PyInstaller apps and any scenario where library is not installed with pip
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
- Install 1.8.1
- 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).
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 1
- Comments: 26 (9 by maintainers)
Links to this issue
Commits related to this issue
- Fix importing google-api-python-client This was a very nonobvious problem. The solution came from a GitHub issue report: https://github.com/googleapis/google-api-python-client/issues/876 — committed to caltechlibrary/lostit by mhucka 4 years ago
- Fix YouTube API connection failure 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 ... — committed to mtsanovv/youspotube by mtsanovv 2 years ago
- hooks: Fix googleapiclient.model missing docs and improve test (#596) The hook googleapiclient.model was raising this warning when running Pyinstaller: WARNING: collect_data_files - skipping data co... — committed to pyinstaller/pyinstaller-hooks-contrib by ArthurKlausHoff a year ago
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
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.
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.
@DrMantisTobbogan yes, it still works for me with latest versions.
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
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.
I get this error also when installing in pip3
module 'googleapiclient' has no attribute '__version__'
@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://github.com/googleapis/google-api-python-client/pull/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().1.8.2 is now released.