gpt4 book ai didi

macos - 无法使用 webapp2/Google App Engine 加载 jinja2

转载 作者:太空宇宙 更新时间:2023-11-03 15:20:34 25 4
gpt4 key购买 nike

我正在我的 Mac 上使用 GoogleAppEngineLauncher 浏览 GAE webapp2 教程(运行时 2.7),尽管我完全按照所有内容进行操作,但在我们导入 Jinja2 模块时我总是遇到错误:Using Templates - Google App Engine

错误:

Traceback (most recent call last): File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 168, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 206, in _LoadHandler handler = import(path[0]) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 640, in Decorate return func(self, *args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1756, in load_module return self.FindAndLoadModule(submodule, fullname, search_path) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 640, in Decorate return func(self, *args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1628, in FindAndLoadModule description) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 640, in Decorate return func(self, *args, **kwargs) File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py", line 1571, in LoadModuleRestricted description) File "/Users/ykessler/Dropbox/appgrinders/gae_apps/helloworld2.7/helloworld.py", line 9, in import jinja2 ImportError: No module named jinja2

所以它出于某种原因找不到模块,即使它应该被打包为 webapp2 的附加组件的一部分。当我搜索我的文件系统时,它看起来就在那里:

/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2_extras/jinja2.py

如果我将应用程序部署到 GAE,它工作正常。为什么会在本地失败?

最佳答案

webapp2 打包它自己的 jinja2 'glue' 模块,这是您要导入的模块,但它不打包 jinja2 本身。如果你想使用它,你需要使用 easy_install 将它安装在你的系统 Python 中,或者将它放在你的应用程序目录中。

关于macos - 无法使用 webapp2/Google App Engine 加载 jinja2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8128830/

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