[英]Cannot Import Flask_Login
I am trying to import flask-login
.我正在尝试导入flask-login
。 When I try doing from flask-login import *
, I get this error:当我尝试from flask-login import *
时,我收到此错误:
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.编辑:我可以做import flask_login
并且它工作得很好,但是当我from flask_login import *
做时它给了我错误。 This error only happens when I try doing from flask_login import *
.仅当我尝试from flask_login import *
时才会发生此错误。 I f I do not import *
it works fine.如果我不import *
它工作正常。
I am using python 3.8.3 64-bit on Windows 10.我在 Windows 10 上使用 python 3.8.3 64 位。
The problem lays in flask_login's init 's first line which is as follows:问题出在 flask_login 的init的第一行,如下所示:
from .__about__ import __version__
importing the string version from the about file:从about文件导入字符串版本:
__version_info__ = ('0', '4', '1')
__version__ = '.'.join(__version_info__)
returning 041, thus 'flask_login.0'返回 041,因此返回 '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:当我手动删除init的第一行(以验证它的问题)时,“from flask_login import *”确实有效,但您不能这样做,因为它不实用,尤其是在服务器端,因此我建议您是否愿意从 flask_login 导入所有内容,仅:
import flask_login as fl
then on your file do something like:然后在您的文件上执行以下操作:
fl.logout_user()
or better, always import just what you need或者更好,总是只导入你需要的东西
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.