2017-03-14 66 views
3

我已經在我的Ubuntu PC上安裝了最新版本的google雲sdk,docs,以便測試google-cloud-endpoints-framework示例appGoogle App Engine:沒有名爲google.api的模塊

但是在調用API請求時,我得到了下面的回溯。好像google包內GAE sdk和google包自動安裝到lib文件夾,因爲google-endpoints包之間有衝突。

$ dev_appserver.py app.yaml 
INFO  2017-03-14 07:51:36,173 devappserver2.py:764] Skipping SDK update check. 
INFO  2017-03-14 07:51:36,199 api_server.py:268] Starting API server at: http://localhost:44561 
INFO  2017-03-14 07:51:36,213 dispatcher.py:199] Starting module "default" running at: http://localhost:8080 
INFO  2017-03-14 07:51:36,213 admin_server.py:116] Starting admin server at: http://localhost:8000 
INFO  2017-03-14 07:51:45,811 module.py:806] default: "GET /_ah/start HTTP/1.1" 404 - 
ERROR 2017-03-14 07:51:45,877 wsgi.py:263] 
Traceback (most recent call last): 
    File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle 
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) 
    File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler 
    handler, path, err = LoadObject(self._handler) 
    File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject 
    obj = __import__(path[0]) 
    File "/home/gemini/gae projects/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/main.py", line 19, in <module> 
    import endpoints 
    File "/home/gemini/gae projects/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/__init__.py", line 29, in <module> 
    from apiserving import * 
    File "/home/gemini/gae projects/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 
    File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/sandbox.py", line 1001, in load_module 
    raise ImportError('No module named %s' % fullname) 
ImportError: No module named google.api 

我試圖創建一個單獨的virtualenv,但問題仍然存在。

+0

這*可能*幫助:http://stackoverflow.com/questions/41399303/using-two-python-libraries-with-conflicting-names。 –

+0

我已經正確設置了app_engine配置文件。但我不能讓它成爲可能..你能提交一個關於這個的錯誤嗎? –

+0

創建了一個問題,希望它會有所幫助.. –

回答

1

我在我的lib目錄與其他谷歌產品類似的問題。 我解決了/猴子在我appengine_config.py文件中使用下面的代碼打補丁吧:

import sys 
import os 
import google 
from google.appengine.ext import vendor 
lib_directory = os.path.dirname(__file__) + "<relative path to lib dir>" 
google.__path__.append(os.path.join(lib_directory, 'google')) 
logging.info("importing lib %s" % (lib_directory)) 
vendor.add(lib_directory) 
+0

試過了,但它不適用於端點v2。 –

1

你的錯誤:

ImportError: No module named google.api 

所以,你需要先安裝gcloud Python模塊和谷歌的API-python-客戶模塊:

pip install --upgrade gcloud 
pip install --upgrade google-api-python-client 

here

+0

您能否在本地測試endpoints v2 API? https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard/endpoints-frameworks-v2/echo/main.py –

相關問題