1

I am using py2exe to compile a set of scripts that rely on the Google Cloud Python API. After compiling, when I run an executable, the following error displays:

  ...
  File "<script_name>.py", line xx, in <module>
    import google.cloud
ImportError: No module named google.cloud

I have done some Googling on the general "ImportError" with py2exe, and the answers I am finding do not seem to apply to my problem.

Any thoughts?

  • I think that you don't have the google.cloud package installed – Sheldon Mar 07 '18 at 19:44
  • I do have the package installed. The script works fine when it is not compiled as an EXE. – Yusuf Siddiqui Mar 07 '18 at 20:34
  • 1
    google-cloud is not on the [list](http://www.py2exe.org/index.cgi/WorkingWithVariousPackagesAndModules) of packages that are known to work with py2exe. – Sheldon Mar 07 '18 at 21:29
  • Have you tried using the `--include package` flag? i.e. `python setup.py py2exe --includes google.cloud` – Sheldon Mar 07 '18 at 21:30
  • I tried doing something similar to the [GoogleProtobuf protocol](http://www.py2exe.org/index.cgi/GoogleProtobuf), i.e. creating empty `__init__.py` files. When I did that, the generated exectuable complained about missing the "appdirs" and "packaging" modules, so I installed those and added those to the "include" tags. After that, the generated executable complained "pkg_resources.DistributionNotFound: The 'google-cloud-storage' distribution was not found and is required by the application". I got stuck at that point. – Yusuf Siddiqui Mar 08 '18 at 17:48

0 Answers0