Loading [MathJax]/jax/output/HTML-CSS/jax.js

Sunday, November 24, 2019

Pyinstaller --- executable file with Google API --- obstacles I have:

  • The first one we come across in many cases should be:
    1
    pkg_resources.DistributionNotFound: The [distribution name] distribution was not found
    where [distribution name] is among {google-*-core, google-cloud-* } for various possible *. The first strategy is reinstallation. To somebody reinstalling the package in trouble will do. To me, I completely reinstall Python from 3.8 to just 3.7.5.

    And in order to keep projects' dependency separate enough, the first package I download is pipenv and installation of the second first package is done in pipenv shell.
  • No module named [sth], to me [sth]'s are respectively google and then google.cloud. I have tried to edit .spec to include these packages as hiddenimports then pyinstaller xxx.spec.

    If problem persists, try to pip show [missing package] to get the location of problematic package, then add this location to pathex. In my case reinstalling Python gets rid of all the problems in this bullet point.
  • After reinstallation, we have a very clean environment, the only problem left to me is again the google-cloud-vision, which is solved by adding hook-google.cloud.py the following

       data += copy_metadata('google-cloud-vision')

  • After we get through all the trouble and successfully build an executable file, we may next encounter :
    1
    Error: Exception in 'grpc._cython.cygrpc.ssl ............ pem_root_certs != nullptr
    To this we create a hook-grpc.py and type the following:
    1
    2
    from PyInstaller.utils.hooks import collect_data_files
    datas = collect_data_files('grpc')
At this point my journey battling with pyinstaller and google api is done, which spent me half of a day to get around all of these problems..., hope this article helps.

No comments:

Post a Comment