python-flask 没有名为 'flask_nav' 的模块
python-flask Nomodule named 'flask_nav'
其实我正在学习python flask Navigation,我成功安装了所有必要的包,这些是一些包,
app$ venv/bin/easy_install flask-restful
app$ venv/bin/easy_install Flask-bootstrap
app$ venv/bin/easy_install Flask-Navigation
但是当我尝试导入时
from flask_nav import Nav
or
from flask_nav.elements import Navbar, View
出现错误,
>>>from flask_nav import register_renderer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'flask_nav'
我正在使用 ubuntu-14.02 和 Python 3.4.3。我该如何解决这个错误,任何解决方案。
根据 Flask-Navigation
文档,您应该导入 Navigation
而不是 Nav
from flask import Flask
from flask.ext.navigation import Navigation
app = Flask(__name__)
nav = Navigation(app)
您可能会混淆 Flask-Navigation
和安装在软件包名称 flask-nav
下的 Flask-Nav
。
从 documentation 开始,Flask-Nav
与 Flask-Navigation
之间存在一些差异:
Flask-Nav owes a some good core ideas to Flask-Navigation, which is
about a year older and the first place the author looked before
deciding to write Flask-Nav. In defense of the reimplementation.
Here are some key differences:
- Flask-Navigation rolls all element types into a single Item class,
which serves as label, view and link element. This makes it a little
hard to extend.
- The HTML generation in Flask-Navigation is done inside
the package itself, while Flask-Nav uses a more complete, external
solution.
- Navigational structure creation and rendering are separate
in Flask-Nav (see Renderer). This allows for more than one way of
rendering the same navbar, allowing other packages (such as
Flask-Bootstrap) to supply renderers as well.
- Some technical choices were deemed a little strange and have been avoided (BoundTypeProperty)
- While Flask-Navigation uses signals and hooks to
regenerate navigation bars on every request, Flask-Nav achieves
dynamic behaviour by lazily instantiating naviigation bars when they
are needed and at the last possible moment.
我得到了答案,还有
$ flask_virtual/bin/easy_install Flask 导航
我们还需要安装 flask-nav 才能访问
from flask_nav import Nav
from flask_nav.elements import Navbar, View
所以使用 $ venv/bin/easy_install --upgrade flask-nav
就我而言,只有这种形式的导入有效:
from flask_navigation import Navigation
参见:
其实我正在学习python flask Navigation,我成功安装了所有必要的包,这些是一些包,
app$ venv/bin/easy_install flask-restful
app$ venv/bin/easy_install Flask-bootstrap
app$ venv/bin/easy_install Flask-Navigation
但是当我尝试导入时
from flask_nav import Nav
or
from flask_nav.elements import Navbar, View
出现错误,
>>>from flask_nav import register_renderer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'flask_nav'
我正在使用 ubuntu-14.02 和 Python 3.4.3。我该如何解决这个错误,任何解决方案。
根据 Flask-Navigation
文档,您应该导入 Navigation
而不是 Nav
from flask import Flask
from flask.ext.navigation import Navigation
app = Flask(__name__)
nav = Navigation(app)
您可能会混淆 Flask-Navigation
和安装在软件包名称 flask-nav
下的 Flask-Nav
。
从 documentation 开始,Flask-Nav
与 Flask-Navigation
之间存在一些差异:
Flask-Nav owes a some good core ideas to Flask-Navigation, which is about a year older and the first place the author looked before deciding to write Flask-Nav. In defense of the reimplementation. Here are some key differences:
- Flask-Navigation rolls all element types into a single Item class, which serves as label, view and link element. This makes it a little hard to extend.
- The HTML generation in Flask-Navigation is done inside the package itself, while Flask-Nav uses a more complete, external solution.
- Navigational structure creation and rendering are separate in Flask-Nav (see Renderer). This allows for more than one way of rendering the same navbar, allowing other packages (such as Flask-Bootstrap) to supply renderers as well.
- Some technical choices were deemed a little strange and have been avoided (BoundTypeProperty)
- While Flask-Navigation uses signals and hooks to regenerate navigation bars on every request, Flask-Nav achieves dynamic behaviour by lazily instantiating naviigation bars when they are needed and at the last possible moment.
我得到了答案,还有 $ flask_virtual/bin/easy_install Flask 导航
我们还需要安装 flask-nav 才能访问
from flask_nav import Nav
from flask_nav.elements import Navbar, View
所以使用 $ venv/bin/easy_install --upgrade flask-nav
就我而言,只有这种形式的导入有效:
from flask_navigation import Navigation
参见: