Yar*_*rin 8 macos google-app-engine webapp2
我正在Mac上使用GoogleAppEngineLauncher浏览GAE webapp2教程(运行时2.7),虽然我正在完全遵循所有内容,但我在导入Jinja2模块时仍然出现错误:使用模板 - Google App Engine
错误:
回溯(最近一次调用最后一次):文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py",第168行,在Handle处理程序中= _config_handle.add_wsgi_middleware(self._LoadHandler())文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py",第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",第640行,在Decorate return func(self,*args,**kwargs)文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",第1756行,在load_module中返回self.FindAndLoadModule(submodule,fullname,search_path)文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",第640行,在Decorate return func( self,*args,**kwargs)在FindAndLoadModule中输入文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",第1628行描述)文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",第640行,装饰返回功能(self,*args ,**kwargs)文件"/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver_import_hook.py",第1571行,在LoadModuleRestricted说明中)文件"/用户/ ykessler/Dropbox/appgrinders/gae_apps/helloworld2.7/helloworld.py",第9行,导入jinja2 ImportError:没有名为jinja2的模块
所以它出于某种原因无法找到该模块,即使它应该被打包为webapp2的附加功能的一部分.当我在我的文件系统上搜索时,它看起来像是在那里:
/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2_extras/jinja2.py
Run Code Online (Sandbox Code Playgroud)
如果我将应用程序部署到GAE,它可以正常工作.为什么会在本地失败?
webapp2打包自己的jinja2'glue'模块,这是你要导入的,但它不包装jinja2本身.如果要使用它,则需要使用easy_install将其安装在系统Python中,或者将其放在应用程序的目录中.
不要latest在app.yaml文件中使用该参数,指定一个版本以防止极不可能但仍然可能存在不兼容的灾难.
libraries:
- name: jinja2
version: "2.6"
Run Code Online (Sandbox Code Playgroud)
然后,在您的脚本中,import jinja2正如我们被文档告知的那样.
| 归档时间: |
|
| 查看次数: |
3425 次 |
| 最近记录: |