Google App Engine 上的 Pyramid 1.2 导致导入错误
我尝试按照此处列出的步骤在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它本身并不是一个真正的解决方案,但我们即将发布新的 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?
除了运行时更新之外,我还找到了另一个解决方法。我已将 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
towebobx
and made pyramid reference the renamedwebobx
module. Not very elegant and will have to be repeated if I get to upgrade pyramid, but works.