当前位置: 代码迷 >> 综合 >> 【已解决】superset创建admin用户失败:Error! User already exists user 或 AttributeError: ‘NoneType‘
  详细解决方案

【已解决】superset创建admin用户失败:Error! User already exists user 或 AttributeError: ‘NoneType‘

热度:44   发布时间:2023-11-18 17:23:07.0

superset创建admin用户失败报错:Error! User already exists user 或者 AttributeError: ‘NoneType’ object has no attribute ‘auth_type’ 解决方法

错误描述

安装superset后发现admin用户登录不上去,执行flask fab create-admin报如下错误:

(superset) [layne@hadoop102 bin]$ flask fab create-admin
Username [admin]: layne
User first name [admin]: 
User last name [user]: 
Email [admin@fab.org]: 
Password: 
Repeat for confirmation: 
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/flask_caching/__init__.py:202: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled."Flask-Caching: CACHE_TYPE is set to null, "
No PIL installation found
INFO:superset.utils.screenshots:No PIL installation found
Recognized Database Authentications.
Error! User already exists layne

按照网上的方法执行fabmanager create-admin --app superset报如下错误:

(superset) [layne@hadoop102 bin]$ fabmanager create-admin --app superset
fabmanager is going to be deprecated in 2.2.X, you can use the same commands on the improved 'flask fab <command>'
Username [admin]: layne
User first name [admin]: 
User last name [user]: 
Email [admin@fab.org]:
Password: 
Repeat for confirmation: 
Traceback (most recent call last):File "/opt/module/miniconda3/envs/superset/bin/fabmanager", line 8, in <module>sys.exit(cli())File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/flask_appbuilder/console.py", line 422, in clicli_app()File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 829, in __call__return self.main(*args, **kwargs)File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 782, in mainrv = self.invoke(ctx)File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 1259, in invokereturn _process_result(sub_ctx.command.invoke(sub_ctx))File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 1066, in invokereturn ctx.invoke(self.callback, **ctx.params)File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 610, in invokereturn callback(*args, **kwargs)File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/flask_appbuilder/console.py", line 137, in create_adminauth_type.get(_appbuilder.sm.auth_type, "No Auth method")
AttributeError: 'NoneType' object has no attribute 'auth_type'

解决方法

删除superset.db数据库文件,重新初始化数据库即可

比如,我目前linux登录用户名layne,我的superset.db文件在/home/layne/.superset/superset.db,删除该文件:

(superset) [layne@hadoop102 ~]$ cd /home/layne/.superset/
(superset) [layne@hadoop102 .superset]$ rm -f superset.db 

然后重新初始化数据库:

(superset) [layne@hadoop102 ~]$ superset db upgrade

再次创建admin用户,发现可以创建成功:

(superset) [layne@hadoop102 ~]$ export FLASK_APP=superset
(superset) [layne@hadoop102 ~]$ flask fab create-admin
Username [admin]: layne
User first name [admin]: 
User last name [user]: 
Email [admin@fab.org]: 
Password: 
Repeat for confirmation: 
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/flask_caching/__init__.py:202: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled."Flask-Caching: CACHE_TYPE is set to null, "
No PIL installation found
INFO:superset.utils.screenshots:No PIL installation found
Recognized Database Authentications.
Admin User layne created.

OK,大功告成!

  相关解决方案