Superset failed to create admin user: Error! User already exists user or AttributeError: ‘NoneType’

created at 08-19-2021 views: 46

Error description

After installing superset, it is found that the admin user cannot log in, and the following error is reported when executing 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

Follow the online method to execute fabmanager create-admin --app superset and get the following error:

(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 cli
    cli_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 main
    rv = self.invoke(ctx)
  File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _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 invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/opt/module/miniconda3/envs/superset/lib/python3.6/site-packages/flask_appbuilder/console.py", line 137, in create_admin
    auth_type.get(_appbuilder.sm.auth_type, "No Auth method")
AttributeError: 'NoneType' object has no attribute 'auth_type'

Solution

Delete the superset.db database file and reinitialize the database

For example, my current Linux login username is layne, and my superset.db file is in /home/layne/.superset/superset.db, delete this file:

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

Then reinitialize the database:

(superset) [layne@hadoop102 ~]$ superset db upgrade
(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, you're done!

created at:08-19-2021
edited at: 08-19-2021: