Get ImportError: No module named control when following google cloud endpoint tutorial

被刻印的时光 ゝ 提交于 2020-01-01 14:59:14

问题


I am following this tutorial on setting up cloud endpoints in python on googles app engine and keep on getting an import error

ImportError: No module named control  

on the Generating the OpenAPI configuration file step when I input

python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname echo-api.endpoints.projectid.cloud.goog

I followed these steps on a new account and still got this error. No idea what I am doing wrong/steps I am skipping.

here is the traceback:

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

any insight would be fabulous


回答1:


I had the same issue using 2.0.0, but using the b2 release instead worked for me. Remove the lib folder and run:

pip install -t lib google-endpoints==2.0.0b2

Using this version will generate a file called echo-v1_swagger.json instead of echov1openapi.json as stated in the documentation, so you'll have to run the following to deploy the config file instead:

gcloud service-management deploy echo-v1_swagger.json




回答2:


This may be because of a library conflict between your environment and the app. This is what this page indicates, and the advice at the end worked for me:

I would recommend activating an empty virtualenv before running endpointscfg.py so that your system packages don't cause issues.

I did this with:

mkdir /tmp/ve
virtualenv /tmp/ve
/tmp/ve/bin/python lib/endpoints/endpointscfg.py ... 



回答3:


It is the same issue reported as #35901199 at the issue tracker, and it was marked as the intended behavior since the Control API is a part of the Google API Client Library and you can run the command 'pip install --upgrade google-api-python-client' to install it, which should solve the 'No module' errors. That said, we should also report this issue at the issue tracker here.



来源:https://stackoverflow.com/questions/41788056/get-importerror-no-module-named-control-when-following-google-cloud-endpoint-tu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!