ImportError:无法导入名称类型

时间:2017-12-23 08:52:09

标签: python google-api

我正在尝试从跟随Github克隆的应用程序。

https://github.com/sfujiwara/qa-system-sample.git (此应用程序使用python flask,Google Natural Language API等。)

但是,我无法在Google App Engine上运行此功能。发生以下错误。

错误:

ImportError: cannot import name types
at <module> (/base/data/home/apps/b~qa-system-sample2/20171223t122211.406411375873194303/lib/google/cloud/language_v1/__init__.py:17)
at <module> (/base/data/home/apps/b~qa-system-sample2/20171223t122211.406411375873194303/lib/google/cloud/language.py:17)
at <module> (/base/data/home/apps/b~qa-system-sample2/20171223t122211.406411375873194303/factoid.py:5)
at <module> (/base/data/home/apps/b~qa-system-sample2/20171223t122211.406411375873194303/main.py:9)
at LoadObject (/base/alloc/tmpfs/dynamic_runtimes/python27/54c5883f70296ec8_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:85)
at _LoadHandler (/base/alloc/tmpfs/dynamic_runtimes/python27/54c5883f70296ec8_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:299)
at Handle (/base/alloc/tmpfs/dynamic_runtimes/python27/54c5883f70296ec8_unzipped/python27_lib/versions/1/google/appengine/runtime/wsgi.py:240)

这发生在lib / google / cloud / language_v1 / _ _init__.py中的from google.cloud.language_v1 import types。  虽然,/ lib / google / cloud / language_v1中有types.py。

我是python的初学者,所以我无法找到导致此错误的原因。请告诉我解决此错误的方法。谢谢。

1 个答案:

答案 0 :(得分:0)

我将枚举添加到库中。它解决了此问题(尽管发生了另一个导入问题)

libraries:
- name: enum
  version: latest