代码之家  ›  专栏  ›  技术社区  ›  Tampa

烧瓶,Bcrypt-importorror:没有名为ext.Bcrypt的模块[副本]

  •  0
  • Tampa  · 技术社区  · 6 年前

    from flask import Flask
    from flask.ext.bcrypt import Bcrypt
    
     Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
    [GCC 5.4.0 20160609] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from flask import Flask
    >>> from flask.ext.bcrypt import Bcrypt
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named ext.bcrypt
    

    我已安装烧瓶bcrypt:

    pip install Flask-Bcrypt
    Requirement already satisfied: Flask-Bcrypt in /usr/local/lib/python2.7/dist-packages (0.7.1)
    Requirement already satisfied: Flask in /usr/local/lib/python2.7/dist-packages (from Flask-Bcrypt) (1.0.2)
    Requirement already satisfied: bcrypt in /usr/local/lib/python2.7/dist-packages/bcrypt-3.1.4-py2.7-linux-x86_64.egg (from Flask-Bcrypt) (3.1.4)
    Requirement already satisfied: Jinja2>=2.10 in /usr/local/lib/python2.7/dist-packages/Jinja2-2.10-py2.7.egg (from Flask->Flask-Bcrypt) (2.10)
    Requirement already satisfied: itsdangerous>=0.24 in /usr/local/lib/python2.7/dist-packages (from Flask->Flask-Bcrypt) (0.24)
    Requirement already satisfied: Werkzeug>=0.14 in /usr/local/lib/python2.7/dist-packages (from Flask->Flask-Bcrypt) (0.14.1)
    Requirement already satisfied: click>=5.1 in /usr/local/lib/python2.7/dist-packages (from Flask->Flask-Bcrypt) (6.7)
    Requirement already satisfied: cffi>=1.1 in /usr/local/lib/python2.7/dist-packages/cffi-1.11.5-py2.7-linux-x86_64.egg (from bcrypt->Flask-Bcrypt) (1.11.5)
    Requirement already satisfied: six>=1.4.1 in /usr/local/lib/python2.7/dist-packages/six-1.10.0-py2.7.egg (from bcrypt->Flask-Bcrypt) (1.10.0)
    Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python2.7/dist-packages/MarkupSafe-1.0-py2.7-linux-x86_64.egg (from Jinja2>=2.10->Flask->Flask-Bcrypt) (1.0)
    Requirement already satisfied: pycparser in /usr/local/lib/python2.7/dist-packages/pycparser-2.18-py2.7.egg (from cffi>=1.1->bcrypt->Flask-Bcrypt) (2.18)
    

    这个错误让我无处可去。我按照这里的文件:

    https://flask-bcrypt.readthedocs.io/en/latest/

    2 回复  |  直到 6 年前
        1
  •  5
  •   ikuamike    6 年前

    尝试使用 from flask_bcrypt import Bcrypt

    这是因为关于烧瓶扩展的烧瓶文档表明 Flask-Foo 并被导入为: from flask_foo import Foo

    http://flask.pocoo.org/docs/1.0/extensions/

        2
  •  1
  •   Sraw    6 年前

    在最近的烧瓶更新中, from flask.ext.xxx import xxx 已删除。你应该直接从它的包中导入它。这里有一个相关的 issue

    顺便说一下,这个软件包似乎过时了(最近一次更新是两年前)。