简体   繁体   中英

Cannot Import Flask_Login

I am trying to import flask-login . When I try doing from flask-login import * , I get this error:

C:\Users\---\Downloads\materials-master\materials-master\flask-google-login>python app.py
Traceback (most recent call last):
  File "app.py", line 8, in <module>
    from flask_login import *
ModuleNotFoundError: No module named 'flask_login.0'

Edit: I can do import flask_login and it works just fine, but when I do from flask_login import * it gives me the error. This error only happens when I try doing from flask_login import * . I f I do not import * it works fine.

I am using python 3.8.3 64-bit on Windows 10.

The problem lays in flask_login's init 's first line which is as follows:

from .__about__ import __version__

importing the string version from the about file:

__version_info__ = ('0', '4', '1')
__version__ = '.'.join(__version_info__)

returning 041, thus 'flask_login.0'

when I manually removed the first line of init (to verify it's the problem), "from flask_login import *" did work, but you can't do this as it's not practical, especially on server side, therefore I suggest if you would like to import everything from flask_login, to just:

import flask_login as fl

then on your file do something like:

fl.logout_user()

or better, always import just what you need

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM