[Superset Installation] The most complete error solution in the superset installation process in history

Table of Contents

1. What is superset?

2. Install superset

3. Initialization of supetset database after installation

1. Error 1: cannot import name ‘url_quote’ from ‘werkzeug.urls’

2. Error 2: AttributeError: module ‘sqlparse.keywords’ has no attribute ‘FLAGS’

3. Mistake 3: You did not provide the “FLASK_APP” environment variable

4. Mistake 4: Refusing to start due to insecure SECRET_KEY

?edit

5. Error 5: ModuleNotFoundError: No module named ‘marshmallow_enum’

4. Create username and password after initialization is completed

5. superset initialization

6. Start Superset

1. Install gunicorn

2. Start Superset

7. Log in to Superset


1. What is superset

Apache Superset is an open source, modern, lightweight BI analysis tool that can connect to multiple data sources, has rich icon display formats, supports customized dashboards, and has a friendly user interface. It is very easy to use because Superset can Connects with commonly used big data analysis tools, such as Hive, Kylin, Druid, etc., and supports custom dashboards, so it can be used as a visualization tool for data warehouses

2. Install superset

It is mainly divided into the following steps:

1. Install gcc compiler

gcc is an open source compiler suite for compiling code in C, C++, and other programming languages

apt install gcc

2. Update the package list

It checks the package manager for available updates and updates its list with the latest version

apt-get update

3. Install or reinstall the necessary packages for the build

build-essential is a software package that contains some basic tools and libraries needed to build software.

apt-get install --reinstall build-essential

4. Install supetset

Start the installation after completing the above stepssupetset

pip install apache-superset -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

3. supetset database initialization after installation

Enter the following command to initializesupetset database

superset db upgrade

During the initialization process, you will encounter various bugs. The following are the solutions

1. Error 1: cannot import name ‘url_quote’ from ‘werkzeug.urls’
Traceback (most recent call last):
  File "/opt/module/miniconda3/envs/superset/bin/superset", line 5, in <module>
    from superset.cli.main import superset
  File "/opt/module/miniconda3/envs/superset/lib/python3.8/site-packages/superset/__init__.py", line 18, in <module>
    from flask import current_app, Flask
  File "/opt/module/miniconda3/envs/superset/lib/python3.8/site-packages/flask/__init__.py", line 7, in <module>
    from .app import Flask as Flask
  File "/opt/module/miniconda3/envs/superset/lib/python3.8/site-packages/flask/app.py", line 27, in <module>
    from .import cli
  File "/opt/module/miniconda3/envs/superset/lib/python3.8/site-packages/flask/cli.py", line 17, in <module>
    from .helpers import get_debug_flag
  File "/opt/module/miniconda3/envs/superset/lib/python3.8/site-packages/flask/helpers.py", line 14, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' 

Cause of error: Caused by the failure to import the url_quote function in the werkzeug library. The possible reason is that you are using an older version of werkzeug and the url_quote function does not exist in that version

Solution: Update werkzeug library

pip install werkzeug==2.2.2 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
2. Error 2: AttributeError: module ‘sqlparse.keywords’ has no attribute ‘FLAGS’
Traceback (most recent call last):
  File "/root/anaconda3/bin/superset", line 5, in <module>
    from superset.cli.main import superset
  File "/root/anaconda3/lib/python3.8/site-packages/superset/__init__.py", line 21, in <module>
    from superset.app import create_app
  File "/root/anaconda3/lib/python3.8/site-packages/superset/app.py", line 23, in <module>
    from superset.initialization import SupersetAppInitializer
  File "/root/anaconda3/lib/python3.8/site-packages/superset/initialization/__init__.py", line 33, in <module>
    from superset.extensions import (
  File "/root/anaconda3/lib/python3.8/site-packages/superset/extensions/__init__.py", line 32, in <module>
    from superset.utils.async_query_manager import AsyncQueryManager
  File "/root/anaconda3/lib/python3.8/site-packages/superset/utils/async_query_manager.py", line 26, in <module>
    from superset.utils.core import get_user_id
  File "/root/anaconda3/lib/python3.8/site-packages/superset/utils/core.py", line 106, in <module>
    from superset.sql_parse import sanitize_clause
  File "/root/anaconda3/lib/python3.8/site-packages/superset/sql_parse.py", line 67, in <module>
    re.compile(r"'(''|\|\|[^'])*'", sqlparse.keywords.FLAGS).match,
AttributeError: module 'sqlparse.keywords' has no attribute 'FLAGS'

Error reason: Caused by the fact that the FLAGS attribute in the sqlparse library does not exist. The possible reason is that the sqlparse version you are using is older and the FLAGS attribute has been removed in that version

Solution:

pip install sqlparse=='0.4.3' -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
3. Error 3: You did not provide the “FLASK_APP” environment variable
Usage: superset [OPTIONS] COMMAND [ARGS]...
Try 'superset --help' for help.

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory.

Cause of error: The FLASK_APP environment variable is not set correctly

Solution:

export FLASK_APP=superset
4. Error 4: Refusing to start due to insecure SECRET_KEY
-------------------------------------------------- ---------------
                                    WARNING
-------------------------------------------------- ----------
A Default SECRET_KEY was detected, please use superset_config.py to override it.
Use a strong complex alphanumeric string and use a tool to help you generate
a sufficiently random sequence, ex: openssl rand -base64 42
-------------------------------------------------- ----------
-------------------------------------------------- ----------
Refusing to start due to insecure SECRET_KEY

Cause of error: The SECRET_KEY configuration of the Flask application is unsafe or weak.

Solution: (The most difficult and important step, open your eyes and look carefully!)

Enter the installation directory of superet. Entervim superset_config.pyAdd configuration file

(Attention!!! The superset_config.py file does not exist originally, you have to create it yourself)

Add the following content under the superset_config.py file:

# Superset specific config
# SS related configuration
# Row limit 5000 rows
ROW_LIMIT = 5000
 
# Website server port 8088, this port is occupied by Hadoop, change it to other ports such as 18088
SUPERSET_WEBSERVER_PORT = 8088
 
# Flask App Builder configuration
# Your App secret key will be used for securely signing the session cookie
# and encrypting sensitive information on the database
# Make sure you are changing this key for your deployment with a strong key.
# You can generate a strong key using `openssl rand -base64 42`
# Flask application builder configuration
# The application key is used to protect the secure signature of the session cookie
# And used to encrypt sensitive information in the database
# Please make sure to select a strong key in your deployment environment
# You can use the command openssl rand -base64 42 to generate a strong key
 
SECRET_KEY = "ZT2uRVAMPKpVkHM/QA1QiQlMuUgAi7LLo160AHA99aihEjp03m1HR6Kg"
 
# The SQLAlchemy connection string to your database backend
# This connection defines the path to the database that stores your
# superset metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
# SQLAlchemy database connection information
# This connection information defines the path to the SS metadata database (slices, connections, tables, data panels, etc.)
# Note: The data source connections and database connections that need to be explored are managed directly through the web interface.
#SQLALCHEMY_DATABASE_URI = 'sqlite:path/to/superset.db'
 
# Flask-WTF flag for CSRF
# Cross-domain request attack identification
WTF_CSRF_ENABLED = True
 
# Add endpoints that need to be exempt from CSRF protection
# CSRF whitelist
WTF_CSRF_EXEMPT_LIST = []
 
# A CSRF token that expires in 1 year
# CSFR token expiration time 1 year
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
 
# Set this API key to enable Mapbox visualizations
# Interface key used to enable Mapbox visualization
MAPBOX_API_KEY = ''

After adding, add the following command to the /etc/profile file: and then take effect the following configuration or restart the big data environment.

(The path should be the absolute path of the superset_config.py file, otherwise the error “Refusing to start due to insecure SECRET_KEY” will always be reported)

export SUPERSET_CONFIG_PATH=/app/superset_config.py
< /h5>

5. Error 5: ModuleNotFoundError: No module named ‘marshmallow_enum’

Cause of error: The code attempts to import the marshmallow_enum module, but the module does not exist in your environment

Solution: Use pip to install the marshmallow_enum module

pip install marshmallow_enum -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

The above are all the bugs I encountered during the installation process. After all the problems are solved, enter superset db upgrade. The superset database initialization is completed and you can proceed to the next step

4. Create user name and password after initialization is completed

The purpose of creating a username and password: Superset uses the flask framework. Flask is a python web framework. Login requires a username and password.

In the anaconda3/bin directory, use the following commands to create a username and password:

(Follow the display to set username and password)

 python superset fab create-admin

5. superset initialization

By executing the superset init command, you can easily initialize the Superset application and configure its running environment. This way, you can start using Superset’s various functions and features as soon as you launch the application.

superset init

6. Start Supterset

1. Install gunicorn

gunicorn is a Python Web Server, which can be compared to Tomcat in java

pip install gunicorn -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
2. Start Superset
gunicorn --workers 5 --timeout 120 --bind 192.168.146.10:8787 "superset.app:create_app()" --daemon 

–workers: Specify the number of processes

–timeout: worker process timeout, it will automatically restart after timeout

–bind: Bind the local address, which is the Superset access address

–daemon: runs in the background

7. Log in to Superset

Visit http://192.168.146.10:8787 and log in using the administrator account created in Section 4

The knowledge points of the article match the official knowledge files, and you can further learn related knowledge. MySQL entry-level skills treeHomepageOverview 77230 people are learning the system