【superset安装】史上最全superset安装过程中错误解决方案

目录

一、superset是什么

二、安装superset

三、安装完之后的supetset数据库初始化

1. 错误一:cannot import name 'url_quote' from 'werkzeug.urls'

2. 错误二:AttributeError: module 'sqlparse.keywords' has no attribute 'FLAGS'

3. 错误三: You did not provide the "FLASK_APP" environment variable

4. 错误四:Refusing to start due to insecure SECRET_KEY

​编辑

5. 错误五:ModuleNotFoundError: No module named 'marshmallow_enum'

四、初始化完成后创建用户名和密码

五、superset初始化

六、启动Supterset

1. 安装gunicorn

2. 启动Superset

七、 登录Superset


一、superset是什么

        Apache Superset是一个开源的、现代的、轻量级BI分析工具,能够对接多种数据源、拥有丰富的图标展示形式、支持自定义仪表盘,且拥有友好的用户界面,十分易用由于Superset能够对接常用的大数据分析工具,如Hive、Kylin、Druid等,且支持自定义仪表盘,故可作为数仓的可视化工具

二、安装superset

主要分为以下几步:

1. 安装gcc编译器

gcc是一个开源的编译器套件,用于编译C、C++和其他编程语言的代码

apt install gcc

2.  更新软件包列表

它会检查软件包管理器的可用更新,并将其列表更新为最新版本

apt-get update

3.  安装或重新安装构建必要的软件包

build-essential是一个软件包,它包含了构建软件所需的一些基本工具和库。

apt-get install --reinstall build-essential

4. 安装supetset

执行完以上步骤后开始安装supetset

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

三、安装完之后的supetset数据库初始化

输入以下命令来初始化supetset数据库

superset db upgrade

在初始化过程中,会遇到各种bug,以下就是是解决方案

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' 

错误原因:由于werkzeug库中的url_quote函数无法导入引起的。可能的原因是你正在使用的werkzeug版本较旧,而url_quote函数在该版本中不存在

解决办法:更新werkzeug库

pip install werkzeug==2.2.2 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
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'

错误原因:由于sqlparse库中的FLAGS属性不存在而引起的。可能的原因是你正在使用的sqlparse版本较旧,而FLAGS属性在该版本中已被移除

解决办法:

pip install sqlparse=='0.4.3' -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
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.

错误原因:没有正确设置FLASK_APP环境变量

解决办法:

export FLASK_APP=superset
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

错误原因:Flask应用程序的SECRET_KEY配置不安全或弱不安全。

解决办法:(最难且重要的一步,睁大眼睛好好看!

进入superet的安装目录下。输入vim superset_config.py增加配置文件

(注意!!! superset_config.py文件原先是没有的,得自己创建

在superset_config.py文件下添加以下内容:

# Superset specific config
# SS 相关的配置
# 行数限制 5000 行
ROW_LIMIT = 5000
 
# 网站服务器端口 8088,该端口被Hadoop占用,改为其他端口比如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 应用构建器配置
# 应用密钥用来保护会话 cookie 的安全签名
# 并且用来加密数据库中的敏感信息
# 请确保在你的部署环境选择一个强密钥
# 可以使用命令 openssl rand -base64 42 来生成一个强密钥
 
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 数据库连接信息
# 这个连接信息定义了 SS 元数据库的路径(切片、连接、表、数据面板等等)
# 注意:需要探索的数据源连接及数据库连接直接通过网页界面进行管理
#SQLALCHEMY_DATABASE_URI = 'sqlite:path/to/superset.db'
 
# Flask-WTF flag for CSRF
# 跨域请求攻击标识
WTF_CSRF_ENABLED = True
 
# Add endpoints that need to be exempt from CSRF protection
# CSRF 白名单
WTF_CSRF_EXEMPT_LIST = []
 
# A CSRF token that expires in 1 year
# CSFR 令牌过期时间 1 年
WTF_CSRF_TIME_LIMIT = 60 * 60 * 24 * 365
 
# Set this API key to enable Mapbox visualizations
# 接口密钥用来启用 Mapbox 可视化
MAPBOX_API_KEY = ''

添加之后,在/etc/profile 文件中加入以下命令:,然后生效以下配置或者重启一下大数据环境即可

(路径写 superset_config.py文件的绝对路径,不然会一直报Refusing to start due to insecure SECRET_KEY的错误

export SUPERSET_CONFIG_PATH=/app/superset_config.py
5. 错误五:ModuleNotFoundError: No module named 'marshmallow_enum'

错误原因:代码中尝试导入marshmallow_enum模块,但该模块在你的环境中不存在

解决办法:使用pip安装marshmallow_enum模块

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

        以上就是我在安装过程中遇到的所有bug,所有问题解决后,再输入superset db upgrade,superset数据库初始化完成,可以进行下一步

四、初始化完成后创建用户名和密码

创建用户名和密码的目的:superset使用的就是flask框架,flask是一个python web框架,登录需要用户名和密码

在anaconda3/bin目录下,使用以下命令来创建用户名和密码:

(按照显示来设置用户名和密码)

 python superset fab create-admin

五、superset初始化

通过执行superset init命令,你可以轻松地初始化Superset应用程序,并配置它的运行环境。这样,你就可以在启动应用程序后开始使用Superset的各种功能和特性。

superset init

六、启动Supterset

1. 安装gunicorn

gunicorn是一个Python Web Server,可以和java中的Tomcat类比

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

--workers:指定进程个数

--timeout:worker进程超时时间,超时会自动重启

--bind:绑定本机地址,即为Superset访问地址

--daemon:后台运行

七、 登录Superset

访问http://192.168.146.10:8787,并使用第四节中创建的管理员账号进行登录

  • 8
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值