Linux8安装Superset 0.38.0过程
官方安装教程:PyPI | Superset (apache.org)
本次安装系统及python环境采用:
Red Hat Enterprise Linux release 8.8
Python 3.6.8
Superset 0.38.0
以下是安装步骤及错误解决过程:
1:OS Dependencies
sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel cyrus-sasl-devel openldap-devel
pip3 install --upgrade pip
pip install --upgrade setuptools pip
2:Installing and Initializing Superset
pip install apache-superset -i https://pypi.tuna.tsinghua.edu.cn/simple/
此时遇到第一个错误:
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决方式:
pip install PyYAML --ignore-installed
上述安装成功后,开始初始化db:
superset db upgrade
此时遇到第二个错误:
Traceback (most recent call last):
File "/usr/local/bin/superset", line 5, in <module>
from superset.cli import superset
File "/usr/local/lib/python3.6/site-packages/superset/__init__.py", line 21, in <module>
from superset.app import create_app
File "/usr/local/lib/python3.6/site-packages/superset/app.py", line 24, in <module>
from flask_appbuilder import expose, IndexView
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/__init__.py", line 5, in <module>
from .api import ModelRestApi # noqa: F401
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/__init__.py", line 21, in <module>
from .convert import Model2SchemaConverter
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/convert.py", line 4, in <module>
from flask_appbuilder.models.sqla.interface import SQLAInterface
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/models/sqla/interface.py", line 40, in <module>
from sqlalchemy_utils.types.uuid import UUIDType
File "/usr/local/lib/python3.6/site-packages/sqlalchemy_utils/__init__.py", line 1, in <module>
from .aggregates import aggregated # noqa
File "/usr/local/lib/python3.6/site-packages/sqlalchemy_utils/aggregates.py", line 372, in <module>
from .functions.orm import get_column_key
File "/usr/local/lib/python3.6/site-packages/sqlalchemy_utils/functions/__init__.py", line 1, in <module>
from .database import ( # noqa
File "/usr/local/lib/python3.6/site-packages/sqlalchemy_utils/functions/database.py", line 11, in <module>
from .orm import quote
File "/usr/local/lib/python3.6/site-packages/sqlalchemy_utils/functions/orm.py", line 14, in <module>
from sqlalchemy.orm.query import _ColumnEntity
ImportError: cannot import name '_ColumnEntity'
原因是在安装superset时默认安装了的SQLAlchemy版本过高,不兼容需要降低版本。
SQLAlchemy 1.4.52
解决方式:
pip install sqlalchemy==1.3.24
继续初始化db,又遇到第三个错误:
Traceback (most recent call last):
File "/usr/local/bin/superset", line 5, in <module>
from superset.cli import superset
File "/usr/local/lib/python3.6/site-packages/superset/__init__.py", line 21, in <module>
from superset.app import create_app
File "/usr/local/lib/python3.6/site-packages/superset/app.py", line 45, in <module>
from superset.security import SupersetSecurityManager
File "/usr/local/lib/python3.6/site-packages/superset/security/__init__.py", line 17, in <module>
from superset.security.manager import SupersetSecurityManager # noqa: F401
File "/usr/local/lib/python3.6/site-packages/superset/security/manager.py", line 44, in <module>
from superset import sql_parse
File "/usr/local/lib/python3.6/site-packages/superset/sql_parse.py", line 18, in <module>
from dataclasses import dataclass
ModuleNotFoundError: No module named 'dataclasses'
原因是库dataclasses是Python3.7以上的版本才会默认安装
解决方式:
pip install dataclasses
继续执行初始化db后成功了。
创建管理员用户:
export FLASK_APP=superset
superset fab create-admin
Username [admin]:
User first name [admin]:
User last name [user]:
Email [admin@fab.org]:
Password:
Repeat for confirmation:
Recognized Database Authentications.
Admin User admin created.
导入一些demo,此处需要开启科学上网,或者自己搭建demo服务
superset load_examples
从Github下载demo文件:apache-superset/examples-data (github.com),上传到服务器后,启动http sever:
python -m http.server 8080
Serving HTTP on 0.0.0.0 port 8080 (http://0.0.0.0:8080/) ...
修改superset安装文件/usr/local/lib/python3.6/site-packages/superset/examples/helpers.py,把BASE_URL修改成:
BASE_URL = "http://localhost:8080/"
然后重新执行:
superset load_examples
开始执行初始化:
superset init
3:Start Superset Server
superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger
打开浏览器访问:http://192.168.142.131:8088/