Skip to main content
 首页 » 编程设计

python之端点教程的 ImportError

2024年10月25日9think

我在使用 GAE 教程时遇到问题。为了开始最基本的工作,我不得不重新安装 pyyaml。

现在我得到:

INFO     2014-12-26 15:06:11,200 module.py:718] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 500 - 
INFO     2014-12-26 15:06:11,203 module.py:718] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60 
ERROR    2014-12-26 20:06:11,236 wsgi.py:263] 
Traceback (most recent call last): 
  File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", 
line 240, in Handle 
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) 
  File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", 
line 299, in _LoadHandler 
    handler, path, err = LoadObject(self._handler) 
  File "C:\Program Files\Google\Cloud SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py", 
line 85, in LoadObject 
    obj = __import__(path[0]) 
ImportError: No module named helloworld_api 

我关注了tutorial到点,多次。每次都出现同样的错误。 我目前试图解决这个问题,看起来像这样:

app.yaml

application: *my id here* 
version: 1 
runtime: python27 
threadsafe: true 
api_version: 1 
 
handlers: 
# Endpoints handler 
- url: /_ah/spi/.* 
  script: helloworld_api.APPLICATION 
 
libraries: 
- name: pycrypto 
  version: latest 
- name: webapp2 
  version: "2.5.2" 
- name: endpoints 
  version: 1.0 

.py 相当长,但它是第 7 步的复制粘贴 here

无论我如何启动它,命令行或 App Engine 启动器,都会发生相同的错误。这看起来很奇怪,因为它清楚地从 Launcher 正常启动,它识别它。服务器启动时没有错误。当我尝试基本教程时,它也运行良好,带有端点的东西不适合我。

我在 API 资源管理器中出现空白屏幕。

文件结构为:

-project 
 -django 
   -helloworld 
    app.yaml 
    helloworld_api.py 
    helloworld.py 

我使用来自 Google Cloud SDK Shell 的 dev_appserver.py helloworld 从 django 目录调用命令

请您参考如下方法:

如果您可以将 helloworld_api.py 的内容添加到您的问题中,我可以查看它并查看是否是问题所在,因为有时使用 Python,您必须准确了解结构的文档,否则它不会被识别为文档。我以前遇到过这个问题。