Superset最新版本安装方法-2021 v_1.0.0

创建环境

我base环境是python3.8,结果用conda安装要么就没这个包,用了conda-forge渠道安装多次,全部失败,最后痛定思痛,还是新建个环境吧,建议用python3.7的版本,兼容性高点。

conda create -n superset python=3.7

安装superset

这里尝试继续使用conda安装,还是一样失败,最后只能选择pip,还挺香的。这里千万注意,是安装apache-superset,不是superset,装完后可以顺便装一下pillow、 pymssql、mysqlclient,建议换国内源。我一般用清华源

(1)阿里云 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
(5)华中科技大学http://pypi.hustunique.com/
pip install apache-superset -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install mysqlclient -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install pymssql -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple/

设置默认的数据库为mysql

修改Lib\site-packages\superset文件下的config.py

SQLALCHEMY_DATABASE_URI = 'mysql://***:***@localhost/***?charset=utf8'

刚才设置的管理员账号的账户名密码也会保存在这个数据库里

配置环境

这次主要就是在这一步走的弯路,国内的教程大部分都是老版本的,按着那个操作新版本会报错。
用这个指令创建管理员账户,

fabmanager create-admin --app superset

会报如下错误

AttributeError: 'NoneType' object has no attribute 'auth_type'

国内的建议大多是换装较早之前版本的superset,我查了github上的issues,有人遇到过同样的问题。解决方法是用新的指令。
cd到site-packages\superset目录下
在这里插入图片描述

set FLASK_APP=app.py
flask fab create-admin

然后按序输入管理账号名称密码等,即可

Username [admin]: ******
User first name [admin]: ******
User last name [user]: ******
Email [admin@fab.org]: ******714@qq.com
Password:
Repeat for confirmation:
logging was configured successfully
INFO:superset.utils.logging_configurator:logging was configured successfully
C:\Users\Admin\.conda\envs\superset\Lib\site-packages\flask_caching\__init__.py:192: UserWarning: Flask-Caching: CACHE_TYPE is set to null, caching is effectively disabled.
  "Flask-Caching: CACHE_TYPE is set to null, "
Recognized Database Authentications.
Admin User ****** created.

接着初始化数据库,加载配置,运行服务

superset db upgrade #初始化数据库
superset init #加载配置
superset run -p 9999 #运行服务,端口号设置为9999

然后就可以登陆了

汉化

汉化包在安装superset时应该已经默认安装了,目录在

site-packages\superset\translations\ru\LC_MESSAGES

只需要cd到superset目录下,运行

(superset) C:\Users\Admin\.conda\envs\superset\Lib\site-packages\superset>pybabel compile -d translations
compiling catalog translations\de\LC_MESSAGES\messages.po to translations\de\LC_MESSAGES\messages.mo
compiling catalog translations\en\LC_MESSAGES\messages.po to translations\en\LC_MESSAGES\messages.mo
compiling catalog translations\es\LC_MESSAGES\messages.po to translations\es\LC_MESSAGES\messages.mo
compiling catalog translations\fr\LC_MESSAGES\messages.po to translations\fr\LC_MESSAGES\messages.mo
compiling catalog translations\it\LC_MESSAGES\messages.po to translations\it\LC_MESSAGES\messages.mo
compiling catalog translations\ja\LC_MESSAGES\messages.po to translations\ja\LC_MESSAGES\messages.mo
compiling catalog translations\ko\LC_MESSAGES\messages.po to translations\ko\LC_MESSAGES\messages.mo
compiling catalog translations\pt_BR\LC_MESSAGES\messages.po to translations\pt_BR\LC_MESSAGES\messages.mo
compiling catalog translations\ru\LC_MESSAGES\messages.po to translations\ru\LC_MESSAGES\messages.mo
compiling catalog translations\zh\LC_MESSAGES\messages.po to translations\zh\LC_MESSAGES\messages.mo

生成messages.mo文件即可。
然后就需要修改之前修改默认数据库的那个config.py文件,来设置默认语言和备选语言。

BABEL_DEFAULT_LOCALE = "zh"  #这里修改默认语言
# Your application default translation path
BABEL_DEFAULT_FOLDER = "superset/translations"
# The allowed translation for you app
""" 
LANGUAGES = {
    "en": {"flag": "us", "name": "English"},
    "es": {"flag": "es", "name": "Spanish"},
    "it": {"flag": "it", "name": "Italian"},
    "fr": {"flag": "fr", "name": "French"},
    "zh": {"flag": "cn", "name": "Chinese"},
    "ja": {"flag": "jp", "name": "Japanese"},
    "de": {"flag": "de", "name": "German"},
    "pt": {"flag": "pt", "name": "Portuguese"},
    "pt_BR": {"flag": "br", "name": "Brazilian Portuguese"},
    "ru": {"flag": "ru", "name": "Russian"},
    "ko": {"flag": "kr", "name": "Korean"},
} 
"""
# Turning off i18n by default as translation in most languages are
# incomplete and not well maintained.
LANGUAGES = {"en": {"flag": "us", "name": "English"},
            "zh": {"flag": "cn", "name": "Chinese"}}
            #这里修改备选语言,11国语言太多,留个中文英语就够了

保存重启就好了

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值