簡體   English   中英

google-app-engine無法運行Cron作業,並出現ImportError:沒有名為gcloud的模塊

[英]google-app-engine fails to run Cron job and gives an ImportError: No module named gcloud

應用程序引擎無法導入已使用的gcloud應用程序gcloud app deploy app.yaml \\ cron.yaml部署到Google App Engine上

在瀏覽器上打開並獲取:

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/base/data/home/apps/s~gcp-project-01/20160916t160552.395688991947248655/main.py", line 18, in <module>
    import update_datastore as ud
  File "/base/data/home/apps/s~vehicle-monitors-api/20160916t160552.395688991947248655/update_datastore.py", line 20, in <module>
    from gcloud import datastore, logging
ImportError: No module named gcloud

app.yaml文件:

    runtime: python27
    api_version: 1
    threadsafe: true

handlers: 
- url: /
  script: main
  login: admin

cron.yaml文件:

 cron:
    - description: run main app
      url: /
      target: main
      schedule: every 2 minutes

requirements.txt文件:

   gcloud==0.14.0

所有第3方軟件包都需要與您的應用安裝在同一目錄中。 從應用程序的根目錄運行此程序以進行安裝。

pip install gcloud -t .

得到它的工作! 使用路徑:

import sys
sys.path.insert(0, 'lib')

額外:
還需要在需求中添加protobuf: protobuf==3.1.0.post1

在google文件夾中創建__init__.py

# this is a namespace package
try:
    import pkg_resources
    pkg_resources.declare_namespace(__name__)
except ImportError:
    import pkgutil
    __path__ = pkgutil.extend_path(__path__, __name__)

也使用pip install -t lib --upgrade protobuf

gcloud==0.18.1

對不起,晚發

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM