Windows 7と最新のwebpyでPython26を使用しています。ImportError:Google App Engineでtemplateという名前のモジュールがありません.Web.py DESTPITEでテンプレートをコンパイルしました
GAEでWeb.pyを設定するための基本的なサンプル(http://webpy.appspot.com/)をコピーし、GAEで使用するためのテンプレートをコンパイルするための手順に従いました(http://webpy.org/ cookbook/templates_on_gae)、その後もImportError:Noという名前のテンプレートがあります。
この問題を抱えている人はたくさんいますが、解決策はテンプレートをコンパイルすることです。これは私がしました;それでも同じエラーです。
私の実装はhttps://bitbucket.org/rhiaro/gae-tutorial(webpyworldディレクトリ内)です。
私のメインファイル、code.pyは次のとおりです。指示は、テンプレートフォルダ内の正しい__ INIT __.pyをもたらしたとしてテンプレートをコンパイル
from google.appengine.ext import db
import web
urls = (
'/', 'index',
'/note', 'note',
'/crash', 'crash'
)
render = web.template.render('templates/')
class Note(db.Model):
content = db.StringProperty(multiline=True)
date = db.DateTimeProperty(auto_now_add=True)
class index:
def GET(self):
notes = db.GqlQuery("SELECT * FROM Note ORDER BY date DESC LIMIT 10")
return render.index(notes)
class note:
def POST(self):
i = web.input('content')
note = Note()
note.content = i.content
note.put()
return web.seeother('/')
class crash:
def GET(self):
import logging
logging.error('test')
crash
app = web.application(urls, globals())
def main():
app.cgirun()
if __name__ == '__main__':
main()
。しかしそれでもモジュールとして認識することはできません。
エラー出力の最後の部分:
path\to\webpyworld\code.py in()
8)
9
10 render = web.template.render('templates/')
11
12 class Note(db.Model):
render undefined, web = <module 'web' from 'D:\gaeTut\webpyworld\web\__init__.pyc'>, web.template = <module 'web.template' from 'D:\gaeTut\webpyworld\web\template.py'>, web.template.render = <class web.template.GAE_Render>
path\to\webpyworld\web\template.py in __init__(self=<web.template.GAE_Render instance>, loc='templates/', *a=(), **kw={})
1031 else:
1032 name = loc.rstrip('/').replace('/', '.')
1033 self.mod = __import__(name, None, None, ['x'])
1034
1035 self.mod.__dict__.update(kw.get('builtins', TEMPLATE_BUILTINS))
self = <web.template.GAE_Render instance>, self.mod undefined, builtin __import__ = <built-in function __import__>, name = 'templates', builtin None = None
<type 'exceptions.ImportError'>: No module named templates
args = ('No module named templates',)
message = 'No module named templates'
少なくとも、完全なスタックトレースとその原因となったコードを含める必要があります。 –
@NickJohnson:ソースはgitリポジトリの上部にリンクされていますが、まだ完全なスタックトレースがありません – KitB