superset db upgrade报错记录
- 报错1
- 报错2
- 报错3
- 报错4
- 报错5
- 报错6
- 成功了
报错1
(superset) [hyj@hadoop102 ~]$ superset db upgrade
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/opt/module/miniconda3/envs/superset/lib/python3.7/site-packages/markupsafe/__init__.py)
解决方法:
- 查看markupsafe这个包是否存在
(superset) [hyj@hadoop102 ~]$ pip show markupsafe
Name: MarkupSafe
Version: 2.1.2
- 下载2.0.1版本的markupsafe (pip会帮我们卸载之前版本的并下载2.0.1版本的markupsafe)
(superset) [hyj@hadoop102 ~]$ pip install markupsafe==2.0.1
报错2
(superset) [hyj@hadoop102 ~]$ superset db upgrade
for ep in importlib_metadata.entry_points().get(namespace, [])
AttributeError: 'EntryPoints' object has no attribute 'get'
解决方法:
(superset) [hyj@hadoop102 ~]$ pip install importlib-metadata==4.13.0
报错3
(superset) [hyj@hadoop102 ~]$ superset db upgrade
from typing import List, Optional, TypedDict, Union
ImportError: cannot import name 'TypedDict' from 'typing' (/opt/module/miniconda3/envs/superset/lib/python3.7/typing.py)
- 这个错误通常是由于Python版本过低导致的,因为 TypedDict 是在Python3.8中引入的。
- 如果你使用的是Python3.7或更早的版本,那么就会出现这个问题。
- 要解决这个问题,
可以将Python版本升级到3.8或者更高的版本
。另外,你也可以使用第三方库typing_extensions来实现类似的功能。
(superset) [hyj@hadoop102 ~]$ python -V
Python 3.7.13
(superset) [hyj@hadoop102 ~]$ conda deactivate
(base) [hyj@hadoop102 ~]$ conda info --envs
# conda environments:
#
base * /opt/module/miniconda3
superset /opt/module/miniconda3/envs/superset(base) [hyj@hadoop102 ~]$ conda remove -n superset --all
(base) [hyj@hadoop102 ~]$ conda create --name superset python=3.8
(base) [hyj@hadoop102 ~]$ conda activate superset
参考链接:ImportError: cannot import name ‘TypedDict’ from ‘typing’
报错4
(superset) [hyj@hadoop102 ~]$ superset db upgrade
re.compile(r"'(''|\\\\|\\|[^'])*'", sqlparse.keywords.FLAGS).match,
AttributeError: module 'sqlparse.keywords' has no attribute 'FLAGS'
解决方法:
(superset) [hyj@hadoop102 ~]$ pip install sqlparse=='0.4.3'
报错5
(superset) [hyj@hadoop102 ~]$ superset db upgrade
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.
解决方法:
(superset) [hyj@hadoop102 ~]$ export FLASK_APP=superset
报错6
(superset) [hyj@hadoop102 ~]$ superset db upgrade
--------------------------------------------------------------------------------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
解决方法:
- 进入到miniconda3的安装路径下的envs/superset/lib/python3.8/目录
(superset) [hyj@hadoop102 ~]$ cd /opt/module/miniconda3/envs/superset/lib/python3.8/
- 创建superset_config.py
(superset) [hyj@hadoop102 python3.8]$ vim superset_config.py
- 添加如下内容
# Superset specific config
# SS 相关的配置
# 行数限制 5000 行
ROW_LIMIT = 5000# 网站服务器端口 8088
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 = ''
- 用命令 openssl rand -base64 42 来生成一个强密钥
- [hyj@hadoop102 ~]$ openssl rand -base64 42
4xPjBius42o5Y/pbgRmkjKZ3im5CeHcRXM93TWm+FboEJOll0XMMgDRW- 所以SECRET_KEY =“4xPjBius42o5Y/pbgRmkjKZ3im5CeHcRXM93TWm+FboEJOll0XMMgDRW”
原文链接:Linux安装miniconda3
成功了
(superset) [hyj@hadoop102 ~]$ superset db upgrade
一连报了6个错,终于成功了。