ImportError:没有名为端点的模块

问题描述 投票:0回答:1

在从github下载的样本目录中设置时正在工作,但是现在我已经构建了自己的API,开发服务器启动但在使用CURL命中它时会抛出此错误:

$ Dev_app server.朋友 ./app.压马路

INFO     2019-03-31 21:48:38,215 api_server.py:275] Starting API server at: http://localhost:54462
INFO     2019-03-31 21:48:38,225 api_server.py:265] Starting gRPC API server at: http://localhost:54464
WARNING  2019-03-31 21:48:38,227 dispatcher.py:338] Your python27 micro version is below 2.7.12, our current production version.
INFO     2019-03-31 21:48:38,386 dispatcher.py:256] Starting module "default" running at: http://localhost:8080
INFO     2019-03-31 21:48:38,395 admin_server.py:150] Starting admin server at: http://localhost:8000
INFO     2019-03-31 21:48:48,055 instance.py:294] Instance PID: 96100
INFO     2019-03-31 21:48:48,076 module.py:861] default: "GET /_ah/start HTTP/1.1" 404 -
ERROR    2019-03-31 21:48:48,113 wsgi.py:263] 
Traceback (most recent call last):
  File "/Users/me/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/Users/me/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "/Users/me/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "/Users/me/Documents/GitHub/activitylogs_api/main.py", line 19, in <module>
    import endpoints
ImportError: No module named endpoints
INFO     2019-03-31 21:48:48,120 module.py:861] default: "GET /_ah/api/activitylogs/v1/list HTTP/1.1" 500 -

但是python -m pip列表显示了这些:

google-endpoints 4.8.0 google-endpoints-api-management 1.11.0

开发服务器是否在某些其他环境的上下文中运行?它在不同的示例文件夹中工作但不在此处。还有一个./lib文件夹,其中包含此命令安装的要求:

pip install --target lib --requirement requirements.txt --ignore-installed

当然,这包括端点......

$ gcloud version
Google Cloud SDK 237.0.0
app-engine-python 1.9.83
app-engine-python-extras 1.9.74
beta 2019.02.22
bq 2.0.42
cloud-datastore-emulator 2.1.0
core 2019.03.01
gsutil 4.37
kubectl 2019.03.01

这是main.py的(开头):

# [START imports]
import endpoints
from endpoints import message_types
from endpoints import messages
from endpoints import remote
from datetime import datetime
# [END imports]

有趣的是,如果我输入python并尝试导入,我会得到一个不同的错误:

$ python
Python 2.7.10 (default, Feb 22 2019, 21:17:52) 
[GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.37.14)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import endpoints
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/me/Library/Python/2.7/lib/python/site-packages/endpoints/__init__.py", line 25, in <module>
    from protorpc import message_types
ImportError: No module named protorpc
>>> 

而python3显示了dev appserver显示的相同错误。但我不知道如何将引擎服务器作为python3启动,因为app.yaml有这个:

runtime:python27

python google-app-engine google-cloud-endpoints
1个回答
0
投票

缺少appengine_config.py:

from google.appengine.ext import vendor

# Add any libraries installed in the `lib` folder.
vendor.add('lib')
© www.soinside.com 2019 - 2024. All rights reserved.