通过Miniconda的Apache Superset安装

Apache Superset 是一个现代化的企业级商业智能 Web 应用程序,快速、轻量和直观。 Superset 支持接入各类数据源,提供了丰富的图表,所有技能组合的用户都可以轻松地对数据进行探索和可视化。

1、Miniconda安装

Miniconda官方的下载链接: https://docs.conda.io/en/latest/miniconda.html#

打开官网后,选择电脑匹配的安装版本安装即可

2、Miniconda验证

conda help

usage: conda-script.py [-h] [-v] [--no-plugins] [-V] COMMAND ...
conda-script.py: error: argument COMMAND: invalid choice: 'help' (choose from 'activate', 'deactivate', 'clean', 'compare', 'config', 'create', 'env', 'export', 'info', 'init', 'install', 'list', 'notices', 'package', 'remove', 'uninstall', 'rename', 'run', 'search', 'update', 'upgrade', 'content-trust', 'doctor', 'repoquery')

能出现这样的结果,就是安装成功了!

3、Superset安装

1)、创建Python环境

conda create -n superset python=3.9

安装过程,是否安装一些新的包,如下。 输入y, 然后继续

第二次安装的时候报错了~~
UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel nvidia <http://mirrors.tuna.tsinghua.edu.cn/anaconda/nvidia>
解决办法

查看配置 conda config --show-sources

查看配置 conda config --show-sources
==> /home/XXXX/.condarc <==
channels:
  - https://repo.continuum.io/pkgs/free/
  - https://repo.continuum.io/pkgs/main/
  - defaults
show_channel_urls: True

修改文件 /home/XXXX/.condarc

  • 原始
  • channels:
      - https://repo.continuum.io/pkgs/free/
      - https://repo.continuum.io/pkgs/main/
      - defaults
    show_channel_urls: True
  • 修改为:
  • channels:
      - defaults
    show_channel_urls: true
    channel_alias: http://mirrors.tuna.tsinghua.edu.cn/anaconda
    default_channels:
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
      - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
    custom_channels:
      conda-forge: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      msys2: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      bioconda: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      menpo: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      pytorch: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
      simpleitk: http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
    

(2)、激活环境

conda activate superset

退出环境
conda deactivate
完全移除环境:
conda remove -n superset --all

(3)、安装apache-superset

pip3 install apache-superset==1.4.2 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
第一次安装失败了~

(4)、处理 C++ 14.0 or greater is required异常

error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [12 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-39
      copying geohash.py -> build\lib.win-amd64-cpython-39
      copying quadtree.py -> build\lib.win-amd64-cpython-39
      copying jpgrid.py -> build\lib.win-amd64-cpython-39
      copying jpiarea.py -> build\lib.win-amd64-cpython-39
      running build_ext
      building '_geohash' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]
安装过程中报了 C++ 14.0 or greater is required的错误
解决办法:下载visiual studio 并打开VisualStudioSetup找到 下图中C++的选项并安装
安装成功后,再次执行上一步“ 安装 apache-superset”的指令,安装成功!

(4)、初始化数据库

superset db upgrade

报错~

(5)、处理MarkupSafe异常

报异常, 异常信息如下:
Traceback (most recent call last):
  File "D:\IDE\install\Anaconda\envs\superset\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\IDE\install\Anaconda\envs\superset\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\IDE\install\Anaconda\envs\superset\Scripts\superset.exe\__main__.py", line 4, in <module>
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\__init__.py", line 18, in <module>
    from flask import current_app, Flask
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\flask\__init__.py", line 14, in <module>
    from jinja2 import escape
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\jinja2\__init__.py", line 12, in <module>
    from .environment import Environment
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\jinja2\environment.py", line 25, in <module>
    from .defaults import BLOCK_END_STRING
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\jinja2\defaults.py", line 3, in <module>
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\jinja2\filters.py", line 13, in <module>
    from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (D:\IDE\install\Anaconda\envs\superset\lib\site-packages\markupsafe\__init__.py)

原因是MarkupSafe版本太高了,所以先卸载,再安装新的版本

pip uninstall MarkupSafe
pip install MarkupSafe==2.0.1
安装完成之后,再次初始化数据库:
superset db upgrade
还是报错

(6)、处理cryptography异常

报异常, 异常信息如下:

Traceback (most recent call last):
  File "D:\IDE\install\Anaconda\envs\superset\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\IDE\install\Anaconda\envs\superset\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\IDE\install\Anaconda\envs\superset\Scripts\superset.exe\__main__.py", line 4, in <module>
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\__init__.py", line 21, in <module>
    from superset.app import create_app
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\app.py", line 23, in <module>
    from superset.initialization import SupersetAppInitializer
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\initialization\__init__.py", line 51, in <module>
    from superset.security import SupersetSecurityManager
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\security\__init__.py", line 17, in <module>
    from superset.security.manager import SupersetSecurityManager  # noqa: F401
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\security\manager.py", line 66, in <module>
    from superset.utils.core import DatasourceName, RowLevelSecurityFilterType
  File "D:\IDE\install\Anaconda\envs\superset\lib\site-packages\superset\utils\core.py", line 71, in <module>
    from cryptography.hazmat.backends.openssl.x509 import _Certificate
ModuleNotFoundError: No module named 'cryptography.hazmat.backends.openssl.x509'

pip install --upgrade cryptography==3.4

安装完成之后,再次初始化数据库:
superset db upgrade
成功~

补充:安装高版本时的报错

(一)处理SECRET_KEY异常
 C:\ProgramData\miniconda3\envs\superset\Lib
-------------------------------------------------------------------------------
                                    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 
————————————————

可以在git bash中生成强密钥

openssl rand -base64 42openssl rand -base64 42

C:\ProgramData\miniconda3\envs\superset\Lib中添加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 = ''
(二)处理 'FLASK_APP' environment异常

Could not locate a Flask application. Use the 'flask --app' option, 'FLASK_APP' environment variable, or a 'wsgi.py' or 'app.py' file in the current directory.

对应的superset根目录为C:\ProgramData\miniconda3\envs\superset,到该目录下重新执行命令

linux环境:

export FLASK_APP=superset

windows环境:

set FLASK_APP=superset

(7)、创建Superset管理员

创建管理员用户:

superset fab create-admin

指定用户名为 admin 、密码为 123456

6)、Superset初始化

初始化: superset init

7)、启动Superset

-h指定监听的IP地址,-p指定端口。

superset run -h 0.0.0.0 -p 8088 --with-threads --reload --debugger
日志:
 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
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
logging was configured successfully
2024-04-29 15:52:55,589:INFO:superset.utils.logging_configurator:logging was configured successfully
2024-04-29 15:52:55,608:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
D:\IDE\install\Anaconda\envs\superset\lib\site-packages\flask_caching\__init__.py:119: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  warnings.warn(
No PIL installation found
2024-04-29 15:52:55,818:INFO:superset.utils.screenshots:No PIL installation found
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
2024-04-29 15:52:57,233:INFO:werkzeug: * Restarting with stat
--------------------------------------------------------------------------------
                                    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
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
logging was configured successfully
2024-04-29 15:52:59,541:INFO:superset.utils.logging_configurator:logging was configured successfully
2024-04-29 15:52:59,563:INFO:root:Configured event logger of type <class 'superset.utils.log.DBEventLogger'>
D:\IDE\install\Anaconda\envs\superset\lib\site-packages\flask_caching\__init__.py:119: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  warnings.warn(
No PIL installation found
2024-04-29 15:52:59,773:INFO:superset.utils.screenshots:No PIL installation found
2024-04-29 15:53:01,104:WARNING:werkzeug: * Debugger is active!
2024-04-29 15:53:01,112:INFO:werkzeug: * Debugger PIN: 330-766-368
2024-04-29 15:53:01,142:INFO:werkzeug: * Running on http://0.0.0.0:8088/ (Press CTRL+C to quit)

然后傻傻地输入“ http://0.0.0.0:8088/”并没有出现该有的页面,一度以为又失败了

后来输入“http://localhost:8088

算安装成功了吧^_^

4、连接SQL Servel 数据库

https://superset.apache.org/docs/configuration/databases/

安装Sql server的Drivers  Drivers :pip install pymssql

mssql+pymssql://webuser:Sesam123!@172.16.34.34:1433/Diw.MES.PlantDataService

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值