gpt4 book ai didi

python - GAE 1.5.5 本地 SDK 无法与 python2.7 runtime 一起运行

转载 作者:太空狗 更新时间:2023-10-29 22:16:49 26 4
gpt4 key购买 nike

GAE 1.5.5看起来有一些优秀的、期待已久的功能。但是,他们还没有为我工作。

我已经下载并安装了 GAE 1.5.5,并且正在使用退化的“AAA”应用程序进行测试。

这大致是我的 app.yaml(为测试做了各种更改)。

应用.yaml

application: AAA # mystical creation.
version: alpha-1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /media
static_dir: media/

- url: /favicon.ico
static_files: media/images/favicon.ico
upload: media/images/favicon.ico

- url: /admin
script: AAA.app
login: admin

- url: /.*
script: AAA.app

skip_files:
- ^(.*/)?app\.yaml

libraries:
- name: django
version: "1.2"
- name: jinja2
version: latest
- name: yaml
version: latest

我在 Mac OS X Lion (10.7.1) 上运行它。

我假设我实际上并没有使用 Python 2.7 运行时,尽管 app.yaml 中声明要使用它。我不太确定如何验证这个理论,但我遇到的错误与它是一致的。这些错误重现如下。

Python路径

当未设置 Google App Engine 的 Python 路径时,应用引擎运行使用 Python 2.6.6。

为了解决这个问题,我在 Google App 中将 Python 路径设置为 /usr/bin/python2.7引擎首选项。

WSGI

我收到以下错误:

 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/
GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/
google/appengine/tools/dev_appserver.py in
GetParentPackage(self=<google.appengine.tools.dev_appserver.HardenedModulesHook
object>, fullname='AAA.app')
2334
2335 if self.find_module(fullname) is None:
=> 2336 raise ImportError('Could not find module %s' %
fullname)
2337
2338 return self._module_dict[parent_module_fullname]
builtin ImportError = <type 'exceptions.ImportError'>, fullname =
'AAA.app'
<type 'exceptions.ImportError'>: Could not find module AAA.app
args = ('Could not find module AAA.app',)
message = 'Could not find module AAA.app'

我尝试过 AAA.app 的地方:

AAA.py:

 from google.appengine.dist import use_library
use_library('django', '1.2') # otherwise we still get django 0.96

from django.core.handlers import wsgi
app = wsgi.WSGIHandler()

AAA/__init__.py

# same content as above

AAA/AAA.py

# same content as above

请注意,我可以继续运行修改了 app.yaml 和 AAA.py 的 CGI,经过必要的修正。然而,这样做仍然会导致以下错误:

神社2

当我运行 import jinja2 时,我得到一个 ImportError

Django2

没有:

from google.appengine.dist import use_library
use_library('django', '1.2')

我最终得到了 Django 0.96。

理论

鉴于以下情况:

  • http://code.google.com/appengine/docs/python/tools/libraries27.html声明“use_library() 函数由google.appengine.dist 包在 Python 2.7 中不可用。”
  • use_library 对我有用
  • use_library 是必需的,因为“库:{django:{...,version: "1.2"}} 声明没有将django版本设置为1.2
  • 只有 Django 1.2 包含在 Python 2.7 运行时中(根据上面的 libraries27.html 链接)
  • 我必须在 Python 路径中手动指定 Python 2.7,以便GAE 使用 Python 2.7
  • WSGI 无法正确加载应用程序
  • 无法导入 Jinja2

我相信我并没有真正使用 Python 2.7 GAE 运行时(即 app.yaml 声明在 GAE 1.5.5 SDK 中被忽略)。

我希望以上描述对您有所帮助,如果您对这里可能发生的事情以及可能的解决方案有任何想法,我将不胜感激。

最佳答案

我有同样的问题,但在 Windows 上,I posted on the Google App Engine forum这是我得到的官方回复:

The Dev server doesn't support 2.7 yet. Currently the only way to test 2.7 based code is on appengine

关于python - GAE 1.5.5 本地 SDK 无法与 python2.7 runtime 一起运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7740319/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com