首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WebPy: AttributeError无模板命名索引

WebPy: AttributeError无模板命名索引
EN

Stack Overflow用户
提问于 2012-10-22 16:49:46
回答 1查看 2.4K关注 0票数 1

最近,我一直在尝试学习WebPy,在尝试使用教程(http://webpy.org/docs/0.3/tutorial)中的模板时,我在尝试访问页面时遇到了这个错误。

代码语言:javascript
复制
File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 239, in process
return self.handle()

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 230, in handle
return self._delegate(fn, self.fvars, args)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 420, in _delegate
return handle_class(cls)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/application.py", line 396, in handle_class
return tocall(*args)

File "/Users/clement/Desktop/#Minecraft/index2.py", line 14, in GET
return render.index(name)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/template.py", line 1017, in __getattr__
t = self._template(name)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/template.py", line 1014, in _template
return self._load_template(name)

File "/Library/Python/2.7/site-packages/web.py-0.37-py2.7.egg/web/template.py", line 1001, in _load_template
raise AttributeError, "No template named " + name

AttributeError: No template named index

我在SOF上看过这个Question,但我无法让它在我的情况下工作。我花了大约4个小时试图弄清楚这一点,并试图按照我启动服务的方式重新工作,通常是通过以下方式完成的:

代码语言:javascript
复制
Macintosh-2:~ clement$ python /Users/clement/Desktop/\#Minecraft/index.py

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2012-10-22 17:07:19

我相信我找到了答案。

解决:

  1. CD进入包含main.py的目录(或者在我的例子中是index.py)
  2. 确保HTML文件位于cd目录中的“模板”目录中
  3. 运行via: Python全文路径到main.py

希望这能帮助有类似问题的人:)

(注:运行OS X 10.8.1)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13016003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档