google-app-engine运行Cron job失败,并给出一个名为gcloud的ImportError: No模



app-engine导入gcloud失败使用gcloud应用部署app.yaml cron。在Google应用引擎上部署Yaml

在浏览器上打开并得到:

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

所有第三方包都需要安装在与你的应用程序相同的目录下。在应用程序的根目录下运行这个命令来安装它。

pip install gcloud -t .

成功了!使用路径:

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

附加:
还需要在需求中添加protobuf:protobuf==3.1.0.post1

创建__init__.py在google文件夹:

# 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 used.

不好意思晚发了

相关内容

  • 没有找到相关文章

最新更新