Superset部署,基于Python3

环境:

python3
centos 7.4

部署:

官网 http://superset.apache.org/installation.html

  1. 安装python 和 其他依赖
sudo yum upgrade python-setuptools
sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel

建议在virtualenv中安装superset,Python 3已经发布了virtualenv。但是如果由于某些原因它没有安装在您的环境中,您可以通过您的操作系统的包安装它,否则您可以从pip安装:

pip install virtualenv

python3 -m venv venv
. venv/bin/activate

一旦您激活了virtualenv,您所做的一切都将被限制在virtualenv中。要退出virtualenv,只需输入deactivate

  1. setuptools pip升级至最新版
pip install --upgrade setuptools pip
  1. 安装Superset
pip install superset
  1. 注册admin用户
fabmanager create-admin --app superset

如果报错:

No module named '_sqlite3'

问题原因:

python3 缺少_sqlite3

解决办法:

需要重新编译包含sqlite3的python3,见安装Python3并包含sqlite3

然后可能又会报错:

Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'

问题原因:

这是 pandas 库版本太高导致的,需要安装低版本的 pandas 库。

解决办法:

查看当前 pandas 版本

pip list | grep pandas
pandas  0.24.2

安装低版本 pandas

pip install pandas==0.23.4

然后重新运行 fabmanager create-admin --app superset 命令创建管理员用户。

  1. 初始化数据库
superset db upgrade

初始化数据库时报错:

sqlalchemy.exc.InvalidRequestError: 
Can't determine which FROM clause to join from, there are multiple FROMS which can join to this entity. 
Try adding an explicit ON clause to help resolve the ambiguity.

问题原因:

这是 SQLAlchemy 库版本太高导致的,需要安装低版本的 SQLAlchemy 库。

解决办法:

查看当前 SQLAlchemy 版本

pip list | grep -i sqlalchemy
Flask-SQLAlchemy 2.3.2   
SQLAlchemy       1.3.2   
SQLAlchemy-Utils 0.33.11

安装低版本 SQLAlchemy

pip install SQLAlchemy==1.2.18

然后重新运行superset db upgrade命令初始化数据库。

  1. 加载样例数据
superset load_examples
  1. 创建默认的角色和权限
superset init
  1. 启动web server, 默认端口8088,使用 -p 绑定其他端口
superset runserver -d
or
superset runserver -d -p 8089

登录

可以使用 http://localhost:8088登录你的superset.

配置superset数据源依赖

databasepypi packageSQLAlchemy URI prefix
MySQLpip install mysqlclientmysql://
Postgrespip install psycopg2postgresql+psycopg2://
Prestopip install pyhivepresto://
Hivepip install pyhivehive://
Oraclepip install cx_Oracleoracle://
sqlitesqlite://
Snowflakepip install snowflake-sqlalchemysnowflake://
Redshiftpip install sqlalchemy-redshiftredshift+psycopg2://
MSSQLpip install pymssqlmssql://
Impalapip install impylaimpala://
SparkSQLpip install pyhivejdbc+hive://
Greenplumpip install psycopg2postgresql+psycopg2://
Athenapip install “PyAthenaJDBC>1.0.9”awsathena+jdbc://
Athenapip install “PyAthena>1.2.0”awsathena+rest://
Verticapip install sqlalchemy-vertica-pythonvertica+vertica_python://
ClickHousepip install sqlalchemy-clickhouseclickhouse://
Kylinpip install kylinpykylin://
BigQuerypip install pybigquerybigquery://
Teradatapip install sqlalchemy-teradatateradata://
Pinotpip install pinotdbpinot+http://controller:5436/ query?server=http://controller:5983/
  1. 安装mysql依赖
pip install mysqlclient  

如果报错:

Collecting mysqlclient
  Downloading http://mirrors.aliyun.com/pypi/packages/f4/f1/3bb6f64ca7a429729413e6556b7ba5976df06019a5245a43d36032f1061e/mysqlclient-1.4.2.post1.tar.gz (85kB)
    100% |████████████████████████████████| 92kB 5.9MB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-hqrD6X/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 51, in get_config
        libs = mysql_config("libs")
      File "setup_posix.py", line 29, in mysql_config
        raise EnvironmentError("%s not found" % (_mysql_config_path,))
    EnvironmentError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hqrD6X/mysqlclient/

去mysqlclient-Github查看https://github.com/PyMySQL/mysqlclient-python

Prerequisites
You may need to install the Python and MySQL development headers and libraries like so:

sudo apt-get install python-dev default-libmysqlclient-dev # Debian / Ubuntu
sudo yum install python-devel mysql-devel # Red Hat / CentOS
brew install mysql-connector-c # macOS (Homebrew) (Currently, it has bug. See below)
On Windows, there are binary wheels you can install without MySQLConnector/C or MSVC.

需要先

yum install python-devel mysql-devel

然后在

pip install mysqlclient

如果报错:

ERROR: Complete output from command python setup.py egg_info:
    ERROR: /bin/sh: mysql_config: command not found

需要安装mariadb-devel

yum install mariadb-devel
  1. 安装pyhive
pip install pyhive

之后就可以支持Presto、Hive、SparkSQL等数据源了。


欢迎访问个人博客:Woods Blog

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值