我跟随本教程在googles应用引擎上设置python中的云端点,并继续获取一个导入错误。
ImportError: No module named control 在上,当我输入时生成OpenAPI配置文件步骤
python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname echo-api.endpoints.projectid.cloud.goog我在一个新帐户上执行了这些步骤,但仍然得到了这个错误。不知道我做错了什么/我跳过的步骤。
这是回溯:
Traceback (most recent call last):
File "lib/endpoints/endpointscfg.py", line 625, in <module>
main(sys.argv)
File "lib/endpoints/endpointscfg.py", line 621, in main
args.callback(args)
File "lib/endpoints/endpointscfg.py", line 479, in _GenOpenApiSpecCallback
application_path=args.application)
File "lib/endpoints/endpointscfg.py", line 324, in _GenOpenApiSpec
application_path=application_path)
File "lib/endpoints/endpointscfg.py", line 181, in GenApiConfig
module = __import__(module_name, fromlist=base_service_class_name)
File "/home/hairyhenry/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/main.py", line 19, in <module>
import endpoints
File "/home/hairyhenry/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/__init__.py", line 29, in <module>
from apiserving import *
File "/home/hairyhenry/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/apiserving.py", line 74, in <module>
from google.api.control import client as control_client
ImportError: No module named control任何洞察力都会是惊人的
发布于 2017-01-25 04:15:22
我在使用2.0.0时也遇到了同样的问题,但是使用b2版本对我有效。删除lib文件夹并运行:
pip install -t lib google-endpoints==2.0.0b2
使用此版本将生成一个名为echo-v1_swagger.json的文件,而不是文档中所述的echov1openapi.json文件,因此您必须运行以下命令来部署配置文件:
gcloud service-management deploy echo-v1_swagger.json
发布于 2017-03-25 17:33:48
这可能是因为您的环境和应用程序之间的库冲突。这就是此页所指出的,最后的建议对我来说是有效的:
我建议在运行endpointscfg.py之前激活一个空的virtualenv,这样您的系统包就不会产生问题。
我这么做是为了:
mkdir /tmp/ve
virtualenv /tmp/ve
/tmp/ve/bin/python lib/endpoints/endpointscfg.py ... 发布于 2017-04-18 20:09:58
同样的问题在问题跟踪器上被报告为#35901199,并且它被标记为预期的行为,因为控制API是Google客户端库的一部分,您可以运行命令'pip -升级google python‘来安装它,这应该可以解决'No模块’错误。也就是说,我们也应该在问题跟踪器上报告这个问题。
https://stackoverflow.com/questions/41788056
复制相似问题