无法运行Flask文档中引用的示例代码 [英] Can't run example code referenced in Flask docs

查看:135
本文介绍了无法运行Flask文档中引用的示例代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读Flask文档,并希望使用他们在git仓库中引用的示例。但是,教程与存储库中的代码不匹配,我无法运行它们;我收到以下错误消息:

$ $ p $ @ app.cli.command('initdb')
AttributeError:'Flask'对象没有属性'cli'

我用 pip install flask 来安装Flask。为什么不能运行repo代码?

解决方案

您正在阅读开发文档,但使用最新的稳定版本0.1)。目前的构建包括许多变化,包括一个cli。要试用最新的代码,请使用:

  pip安装https://github.com/mitsuhiko/flask/tarball/master 

要在最新的稳定版本中获得类似的内容,您需要编写自己的命令或使用第三方扩展如Flask-Script。一个新的扩展,Flask-CLI,将新的Click接口从master转换为稳定版本。


I am reading the Flask docs and want to use the examples they reference that are in the git repo. However, the tutorials don't match the code in the repository, and I can't run them; I get the following error:

  @app.cli.command('initdb')
AttributeError: 'Flask' object has no attribute 'cli'

I used pip install flask to install Flask. Why can't I run the repo code?

解决方案

You are reading the development docs, but using the latest stable release (0.10.1). The current builds include many changes, including a cli. To try out the latest code, use:

pip install https://github.com/mitsuhiko/flask/tarball/master

To get something similar in the latest stable release, you either need to write your own commands or use a third-party extension such as Flask-Script. A new extension, Flask-CLI, backports the new Click interface from master to the stable version.

这篇关于无法运行Flask文档中引用的示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆