ImportError:App Engine App上没有名为cloud的模块

时间:2017-10-29 13:29:16

标签: python google-app-engine google-cloud-vision

我尝试在app引擎上部署我的python脚本但遇到错误:“ImportError:没有名为cloud的模块”。

我做了Installing a third-party library manual中的所有事情。但它不起作用:(

所以,我有:

1)app.yaml:

runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /.*
  script: main.py

2)appengine_config.py

# appengine_config.py
from google.appengine.ext import vendor
# Add any libraries install in the "lib" folder.
vendor.add('lib')

3)requirements.txt

googleapis-common-protos==1.5.3
google-cloud-vision==0.27.0
google-gax==0.15.15
google-resumable-media==0.3.1
google-api-python-client==1.6.4
google-auth==1.1.1

4)包含来自

的所有库的lib文件夹
Used command:
pip install -t lib -r requirements.txt

5)使用google cloud vision lib的main.py。

from google.cloud import vision # Imports the Google Cloud client library
from google.cloud.vision import types # Imports the Google Cloud client library
import os

def detect_labels_uri(uri):

# Setup Credentials
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'my_servive_acc_key.json'

def detect_labels_uri(uri):
    client = vision.ImageAnnotatorClient()
    image = types.Image()
    image.source.image_uri = uri

    response = client.label_detection(image=image)
    labels = response.label_annotations
    print('Labels:')

    for label in labels:
        print 'Content-Type: text/plain'
        print ''
        print(label.description)

try:
    detect_labels_uri('https://i.ytimg.com/vi/gqYlS_r8I-Y/maxresdefault.jpg')
except:
    print 'Content-Type: text/plain'
    print ''
    print 'Oops! That was no valid URL. Try again...'

错误:

Traceback (most recent call last): (/base/data/home/runtimes/python27_experiment/python27_lib/versions/1/google/appengine/runtime/cgi.py:122)
  File "/base/data/home/apps/h~test-184307/20171029t190420.405148744830706371/main.py", line 7, in <module>
    from google.cloud import vision # Imports the Google Cloud client library
ImportError: No module named cloud

你能帮我理解我错在哪里吗?

0 个答案:

没有答案