简体   繁体   中英

How to use google cloud vision with Google App Engine Python?

I am trying to use https://cloud.google.com/vision/ in my Google App Engine Python application. Are there examples for using it?

I followed the tutorial: https://www.programmableweb.com/news/how-to-build-monitoring-application-google-cloud-vision-api/how-to/2016/03/29?page=4

and

I am getting an error when I use the following after enabling the Cloud-Vision API in the API manager:

from googleapiclient.discovery import build
from oauth2client.client import GoogleCredentials

Error

   from googleapiclient.discovery import build
ImportError: No module named googleapiclient.discovery

Am I missing a dependency configuration?

You should be able to use their official client libraries in your app engine project like any other API. Just make sure to enable the specific API for your specific project in the API Manager [0].

There's also a repo with sample code for various languages although not app engine specific [1]

Accessing Google APIs from Python

For your App Engine project, run this to install the client library first. This is considered a third party library, so you will need some initial setup for your app engine project as described here [2] -

$ mkdir lib
$ pip install --upgrade -t lib google-api-python-client

Create a file appengine_config.py with the following content -

# appengine_config.py
from google.appengine.ext import vendor

# Add any libraries install in the "lib" folder.
vendor.add('lib')

You can find more information about the client library here -

https://developers.google.com/api-client-library/python/

Feel free to update your question with more specific issues you are having including some sample code you've tried and I'd be happy to provide more assistance.

[0] https://console.cloud.google.com/apis/api/vision.googleapis.com/overview

[1] https://github.com/GoogleCloudPlatform/cloud-vision

[2] https://cloud.google.com/appengine/docs/standard/python/tools/using-libraries-python-27#vendoring

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM