ImportError: No module named flask.ext.login

前端 未结 8 1992
刺人心
刺人心 2021-02-06 22:54

I have a problem with flask_login module.

i have installed flask_login module successfully. Also from the command prompt i can run this script easily with no error:

相关标签:
8条回答
  • 2021-02-06 23:09

    The solution is simple. Different versions of the flask run with different codes so just change the code : flask.ext.login to the code: flask_login

    It should run smoothly.

    Note that this also applies to bootstrap. Actually inorder to find the solution I had the error while importing bootstrap.

    0 讨论(0)
  • 2021-02-06 23:11

    Strange But it worked when I tried to run the script from Command prompt

    C:\Users\dib\Desktop>python foo.py
     * Running on http://127.0.0.1:5000/
    127.0.0.1 - - [11/Feb/2014 18:03:52] "GET / HTTP/1.1" 200 -
    

    But when I am trying to run from the python default IDE pressing f5 it is not working.

    0 讨论(0)
  • 2021-02-06 23:20

    Install pip and then use the following command:

    C:\Python27\scripts>pip install Flask-Login

    0 讨论(0)
  • 2021-02-06 23:21

    See For me the simple solution is to just remove .ext from flask.ext.login and instead just type flask_login. This works for python 3 and make sure that you have correctly installed your desired package.

    0 讨论(0)
  • 2021-02-06 23:24

    If following does not work:

    from flask.ext.login import LoginManager
    

    try the following:

    from flask_login import LoginManager
    

    This is the new convention.

    To find the flask-login version, you can run the following command in terminal. Just change the name to know the version of other packages.

    pip show flask-login
    
    0 讨论(0)
  • 2021-02-06 23:24

    If you have already installed flask-login by

    $pip install flask_login
    

    Try replacing the

    from flask.ext.login import LoginManager
    

    with

    from flask_login import LoginManager
    
    0 讨论(0)
提交回复
热议问题