Google App Engine 上的 Pyramid 1.2 导致导入错误

发布于 2024-12-07 15:08:10 字数 1027 浏览 1 评论 0原文

我尝试按照此处列出的步骤在 GAE 上运行 Pyramid 。在开发服务器上一切正常,但是当部署到 Google 的服务器上时,会出现以下错误:

<type 'exceptions.ImportError'>: cannot import name BaseRequest
Traceback (most recent call last):
  File "/base/data/home/apps/.../0-0-1.353634463095353211/main.py", line 9, in <module>
    from pyramid.config import Configurator
  File "/base/data/home/apps/.../0-0-1.353634463095353211/lib/dist/pyramid/__init__.py", line 1, in <module>
    from pyramid.request import Request
  File "/base/data/home/apps/.../0-0-1.353634463095353211/lib/dist/pyramid/request.py", line 6, in <module>
    from webob import BaseRequest

这可能是由于 GAE 使用 WebOb 0.9 而 Pyramid 使用 WebOb 1.1 (它驻留在 lib/dist/webob 在我的项目中),因为 0.9 中缺少 BaseRequest

在 main.py 文件中有这个片段:

sys.path.insert(0,'lib/dist')

但它似乎只对开发服务器情况有帮助。我有办法强制 GAE 运行时使用我的应用程序中包含的版本 1.1 吗?

I'm trying to run Pyramid on GAE by following the steps outlined here. Everything works fine on dev server, but when deployed to Google's servers, the following error occurs:

<type 'exceptions.ImportError'>: cannot import name BaseRequest
Traceback (most recent call last):
  File "/base/data/home/apps/.../0-0-1.353634463095353211/main.py", line 9, in <module>
    from pyramid.config import Configurator
  File "/base/data/home/apps/.../0-0-1.353634463095353211/lib/dist/pyramid/__init__.py", line 1, in <module>
    from pyramid.request import Request
  File "/base/data/home/apps/.../0-0-1.353634463095353211/lib/dist/pyramid/request.py", line 6, in <module>
    from webob import BaseRequest

This is probably caused by the fact that GAE uses WebOb 0.9 while Pyramid uses WebOb 1.1 (it resides under lib/dist/webob in my project), since BaseRequest is missing in 0.9.

In the main.py file there is this fragment:

sys.path.insert(0,'lib/dist')

but it seems to help only for dev server case. I there a way to force GAE runtime to use version 1.1 included in my application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧夏天 2024-12-14 15:08:11

它本身并不是一个真正的解决方案,但我们即将发布新的 Python 运行时 Python 2.7,其中包括库的更新版本,包括 webob 1.1。也许您可以将您的应用程序针对该目标,而不是针对 2.5 运行时?

It's not really a solution, per-se, but we're about to release the new Python runtime, Python 2.7, which includes updated versions of libraries, including webob 1.1. Perhaps you could target your app against that, instead of against the 2.5 runtime?

烂柯人 2024-12-14 15:08:11

除了运行时更新之外,我还找到了另一个解决方法。我已将 WebOb 1.1 模块从 webob 重命名为 webobx ,并使金字塔引用重命名的 webobx 模块。不是很优雅,如果我要升级金字塔,则必须重复,但可以。

Apart from the runtime update, I found another workaround. I've renamed the WebOb 1.1 module from webob to webobx and made pyramid reference the renamed webobx module. Not very elegant and will have to be repeated if I get to upgrade pyramid, but works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文