I want to use Google Cloud Vision label detection in a simple App Engine webapp2 project. ( combine https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/vision/cloud-client/quickstart and https://github.com/GoogleCloudPlatform/python-docs-samples/tree/6f5f3bcb81779679a24e0964a6c57c0c7deabfac/appengine/standard/hello_world). when the app is deployed to app engine "ImportError: cannot import name cygrpc" is produced and fails import "from google.cloud import vision", even after adding "grpcio==1.25.0" to the requirements.txt file the error remains.
quickstart.py
import webapp2
import io
import os
from google.cloud import vision
from google.cloud.vision import types
class MainPage(webapp2.RequestHandler):
def get(self):
client = vision.ImageAnnotatorClient()
file_name = os.path.abspath('resources/wakeupcat.jpg')
with io.open(file_name, 'rb') as image_file:
content = image_file.read()
image = types.Image(content=content)
response = client.label_detection(image=image)
labels = response.label_annotations
print('Labels:')
for label in labels:
print(label.description)
app = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
requirements.txt
google-cloud-vision==0.39.0
app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: quickstart.app
libraries:
- name: ssl
version: latest
appengine_config.py
from google.appengine.ext import vendor
vendor.add('lib')
Created resources folder with wakeupcat.jpp. And then created lib folder "pip install -r requirements.txt -t lib" to install the libraries.