[PYTHON] A story that an error occurred when PyInstaller was used in a program that uses googleapiclient

problem

When I tried to create an executable file with PyInstaller for a program that uses Google Api (spreadsheet), I was able to compile it, but an error occurred at runtime. The compiled program looks like this

main.py


from googleapiclient.discovery import build
#The following is omitted

here,

pyinstaller --onefile main.py
./dist/main #Compiles successfully and an executable file is created

Now, when you execute the executable file,

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

:middle_finger_tone2::laughing::middle_finger_tone2:

Solutions

Set the version of google-api-client to *** 1.8.0 ***. The point is to do the following:

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

What a breakthrough solution! !! !! !!

Details

For reference only, the execution environment is

in conclusion

When using google-could-vision or Firestore I saw an article about similar errors, but it wasn't very helpful. In each example, I encountered pkg_resources.DistributionNotFound, so I thought I could go with the same solution, but I couldn't do it at all and the time melted. After all, it was solved by issue discussion on github of google-api-client. I tried cx_Freeze as an alternative to PyInstaller, but I couldn't do it after all. I don't know how long this problem will occur (until PyInstaller / Google supports it?), And I don't know how long this method will solve it, so please use it as a reference. I also wanted Python to establish a method to make it an official (cross-platform) executable file like Golang.

Recommended Posts

A story that an error occurred when PyInstaller was used in a program that uses googleapiclient
A story that stumbled when using pip in a proxy environment
A story that I wondered if it stopped working at mglearn.plots.plot_nmf_faces and was an error?
The story that a hash error came out when using Pipenv
A story about a build error in a shared library that references libusb
An error occurred in scikit-learn imputer
When writing a program in Python
An error that does not work as expected when calling the tkinter module in a text editor
The story of an error in PyOCR
When I get an error with PyInstaller
[Python3] Code that can be used when you want to cut out an image in a specific size
The story that an error occurred in pyenv install (It is an epic story, and the critical cause is unknown after all)
In the Chainer tutorial, I get an error when importing a package. (mock)
A story that I was addicted to when I made SFTP communication with python
Error that occurred in OpenCV3 and its solution Precautions when using OpenCV3 on Mac
When I get a chromedriver error in Selenium
Error details and countermeasures that occurred in OpenCv2 when executing the object recognition sample program of "Object Detect on Tools"
Building an environment that uses Python in Eclipse
A program that removes duplicate statements in Python
Create an exe file that works in a Windows environment without Python with PyInstaller
Convert a path string that uses a symbolic link in the middle to an absolute path
A note that runs an external program in Python and parses the resulting line
A story about an error when loading a TensorFlow model created with Google Colab locally
Error in Pyinstaller
A story that Seaborn was easy, convenient and impressed
Story that an inexperienced person made a masked solver
I get an error when I put opencv in pyautoGUI
What's in that variable (when running a Python script)
A shell program that becomes aho in multiples of 3
A story that I was addicted to at np.where
A memorandum when an error occurs with pip install
When you get an error in python scraping (requests)
A story that was terrible if SELinux was properly disabled
A story about PHP that was okay in the development environment but buggy in the production environment LEVEL 1-3 + 1
Check the argument type annotation when executing a function in Python and make an error
Summary of points to keep in mind when writing a program that runs on Python 2.5
A story that went missing when I specified a path starting with a tilde (~) in python open
The story I was addicted to when I specified nil as a function argument in Go