flask-admin 基本示例抛出 builtins.AttributeError 异常
flask-admin basic example throws builtins.AttributeError exception
不确定我做错了什么。我正在遵循 flask-admin 的快速入门指南(link) and just tried running the basic example provided under the Initialization section。当我 运行 该代码并浏览到 localhost:5000/admin/ 时,我收到以下错误
builtins.AttributeError
AttributeError: 'For' 对象没有属性 'test'
如果有帮助,我也可以粘贴详细的异常堆栈。
我怀疑缺少依赖项并尝试重新安装 flask-admin,但没有帮助。这是我的 pip freeze 输出:
$ pip freeze
APScheduler==3.3.1
click==6.7
dominate==2.3.1
Flask==0.12.2
Flask-Admin==1.5.0
Flask-APScheduler==1.7.0
Flask-Bootstrap==3.3.7.1
Flask-SQLAlchemy==2.2
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
python-dateutil==2.6.1
pytz==2017.2
six==1.10.0
SQLAlchemy==1.1.13
SQLAlchemy-Utils==0.32.14
tzlocal==1.4
visitor==0.1.3
Werkzeug==0.12.2
WTForms==2.1
我正在使用 python 3.6.1
我的代码与示例完全一样:
from flask import Flask
from flask.ext.admin import Admin
app = Flask(__name__)
admin = Admin(app)
app.run()
这是异常堆栈:
Traceback (most recent call last):
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\project\.venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 69, in inner
return self._run_view(f, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 368, in _run_view
return fn(self, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 452, in index
return self.render(self._template)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 308, in render
return render_template(template, **kwargs)
File "c:\project\.venv\lib\site-packages\flask\templating.py", line 134, in render_template
context, ctx.app)
File "c:\project\.venv\lib\site-packages\flask\templating.py", line 116, in _render
rv = template.render(context)
File "c:\project\.venv\lib\site-packages\jinja2\asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "c:\project\.venv\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "c:\project\.venv\lib\site-packages\jinja2\_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "c:\project\.venv\lib\site-packages\flask_admin\templates\bootstrap2\admin\index.html", line 1, in top-level template code
{% extends 'admin/master.html' %}
File "c:\project\.venv\lib\site-packages\flask_admin\templates\bootstrap2\admin\master.html", line 1, in top-level template code
{% extends admin_base_template %}
File "c:\project\.venv\lib\site-packages\jinja2\environment.py", line 543, in _generate
optimized=self.optimized)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 82, in generate
generator.visit(node)
File "c:\project\.venv\lib\site-packages\jinja2\visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 772, in visit_Template
self.blockvisit(block.body, block_frame)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 372, in blockvisit
self.visit(node, frame)
File "c:\project\.venv\lib\site-packages\jinja2\visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 1130, in visit_If
self.blockvisit(node.body, if_frame)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 372, in blockvisit
self.visit(node, frame)
File "c:\project\.venv\lib\site-packages\jinja2\visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 1014, in visit_For
if node.test:
AttributeError: 'For' object has no attribute 'test'
将不胜感激任何建议。
我怀疑我搞砸了我的 venv。我再次尝试使用全新的 venv,安装了所有软件包,现在一切正常。希望这对某人有所帮助。
不确定我做错了什么。我正在遵循 flask-admin 的快速入门指南(link) and just tried running the basic example provided under the Initialization section。当我 运行 该代码并浏览到 localhost:5000/admin/ 时,我收到以下错误
builtins.AttributeError
AttributeError: 'For' 对象没有属性 'test'
如果有帮助,我也可以粘贴详细的异常堆栈。
我怀疑缺少依赖项并尝试重新安装 flask-admin,但没有帮助。这是我的 pip freeze 输出:
$ pip freeze
APScheduler==3.3.1
click==6.7
dominate==2.3.1
Flask==0.12.2
Flask-Admin==1.5.0
Flask-APScheduler==1.7.0
Flask-Bootstrap==3.3.7.1
Flask-SQLAlchemy==2.2
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
python-dateutil==2.6.1
pytz==2017.2
six==1.10.0
SQLAlchemy==1.1.13
SQLAlchemy-Utils==0.32.14
tzlocal==1.4
visitor==0.1.3
Werkzeug==0.12.2
WTForms==2.1
我正在使用 python 3.6.1
我的代码与示例完全一样:
from flask import Flask
from flask.ext.admin import Admin
app = Flask(__name__)
admin = Admin(app)
app.run()
这是异常堆栈:
Traceback (most recent call last):
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "c:\project\.venv\lib\site-packages\flask\_compat.py", line 33, in reraise
raise value
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "c:\project\.venv\lib\site-packages\flask\app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 69, in inner
return self._run_view(f, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 368, in _run_view
return fn(self, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 452, in index
return self.render(self._template)
File "c:\project\.venv\lib\site-packages\flask_admin\base.py", line 308, in render
return render_template(template, **kwargs)
File "c:\project\.venv\lib\site-packages\flask\templating.py", line 134, in render_template
context, ctx.app)
File "c:\project\.venv\lib\site-packages\flask\templating.py", line 116, in _render
rv = template.render(context)
File "c:\project\.venv\lib\site-packages\jinja2\asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "c:\project\.venv\lib\site-packages\jinja2\environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "c:\project\.venv\lib\site-packages\jinja2\_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "c:\project\.venv\lib\site-packages\flask_admin\templates\bootstrap2\admin\index.html", line 1, in top-level template code
{% extends 'admin/master.html' %}
File "c:\project\.venv\lib\site-packages\flask_admin\templates\bootstrap2\admin\master.html", line 1, in top-level template code
{% extends admin_base_template %}
File "c:\project\.venv\lib\site-packages\jinja2\environment.py", line 543, in _generate
optimized=self.optimized)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 82, in generate
generator.visit(node)
File "c:\project\.venv\lib\site-packages\jinja2\visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 772, in visit_Template
self.blockvisit(block.body, block_frame)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 372, in blockvisit
self.visit(node, frame)
File "c:\project\.venv\lib\site-packages\jinja2\visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 1130, in visit_If
self.blockvisit(node.body, if_frame)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 372, in blockvisit
self.visit(node, frame)
File "c:\project\.venv\lib\site-packages\jinja2\visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "c:\project\.venv\lib\site-packages\jinja2\compiler.py", line 1014, in visit_For
if node.test:
AttributeError: 'For' object has no attribute 'test'
将不胜感激任何建议。
我怀疑我搞砸了我的 venv。我再次尝试使用全新的 venv,安装了所有软件包,现在一切正常。希望这对某人有所帮助。