0

I am attempting to make a web app with flask, and when I attempt to run my script through the command line, I get a "ModuleNotFoundError: No module named 'google.cloud'". However, when I run the script in Sublime, I do not get this error.

I have already attempted installing google, google-cloud, and conda using pip.

Here are the lines that are involved in importing from google.cloud. The console states that the first line is the one the compilation is failing at.

from google.cloud import vision
from google.cloud.vision import types

I was expecting the code to be output to my localhost, but this compile time error is preventing this.

davidism
  • 121,510
  • 29
  • 395
  • 339

1 Answers1

0

The library|package that you need is called google-cloud-vision, see:

https://pypi.org/project/google-cloud-vision/

You could add this directly to your project (at its current version) using:

pip install "google-cloud-vision==0.36.0"

However... Your problem may be a consequence of different python environments and I encourage you to review virtualenv:

https://virtualenv.pypa.io/en/latest/

Among other things, virtualenv enables (a) the creation of isolated python environments; (b) "clean room" like behavior wherein you can recreate python environments easily and predictably. This latter benefit may help with your "it works .... but doesn't work ... " issue.

One additional good practice, with|without virtualenv is to persist pip install ... to (conventionally) requirements.txt:

pip install -r requirements.txt

And, in this case, to have requirements.txt similar to:

flask==1.0.2
google-cloud-vision==0.36.0
DazWilkin
  • 32,823
  • 5
  • 47
  • 88
  • I did try your suggestion to use "pip install "google-cloud-vision==0.36.0", however, the problem continues to persist. Also, I am currently using a virtual environment for this project. – EagleBeagle Mar 23 '19 at 03:21
  • Also, I'm not sure if this is relevant, but when I did "pip install "google-cloud-vision==0.36.0", the console gave this error: Command "python setup.py egg_info" failed with error code 1 in C:\Users\\AppData\Local\Temp\pip-install-ke726vww\googleapis-common-protos\ – EagleBeagle Mar 23 '19 at 03:32
  • See this answer: https://stackoverflow.com/a/54836800/609290. You'd mentioned installing `google-cloud` but you should not use that library. Try to uninstall that and try again. – DazWilkin Mar 23 '19 at 03:34
  • Yes, the error you received is relevant. You may wish to try upgrading setuptools and trying that again: `pip install --upgrade setuptools` – DazWilkin Mar 23 '19 at 03:41
  • Thank you so much for the answer. It is working now. – EagleBeagle Mar 23 '19 at 14:31