windows10 安装superset

325 阅读2分钟

需提前安装 Anaconda,官网或清华等镜像下载个人版

创建虚拟环境

Superset 的依赖包较多,为了避免冲突,需要先搭建虚拟环境,再进行安装

一、安装虚拟环境

conda create -n superset python=3.7

安装过程出现的问题

依赖包下载失败 CondaHTTPError: HTTP 000 CONNECTION FAILED for url repo.anaconda.com/pkgs/main/w… Elapsed: - An HTTP error occurred when trying to retrieve this URL. HTTP errors are often intermittent, and a simple retry will get you on your way.

解决方法

配置conda镜像,使用国内镜像服务器下载安装虚拟环境

# 1、添加镜像
# 中科大镜像
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ 
# 清华镜像
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
# 2、设置从channel中安装包时显示channel的url,这样就可以知道包的安装来源了。
conda config --set show_channel_urls yes

二、切换虚拟环境

//开启superset虚拟环境
activate superset
//关闭虚拟环境
deactivate

安装superset

一、安装superset

pip install superset -i https://pypi.douban.com/simple

二、安装apache-superset

pip install apache-superset -i https://pypi.douban.com/simple

可能会出现如下错误

apache-superset.png apache-superset_error.png 解决方法:

问题的实质是没有装上python-geohash,这是因为该依赖包需要安装 C++ 进行编译,一般不用为此专门安装 Microsoft Visual C++ 14.0,而是去下载该依赖包的 whl 格式文件(需要对应虚拟环境的 python 版本),再进入 whl 文件所在的路径通过 pip install 安装即可。

whl格式本质上是一个压缩包,里面包含了py文件,以及经过编译的pyd文件。使得可以在不具备编译环境的情况下,选择合适自己的python环境进行安装

安装过程: 打开python扩展包工具站,搜索相应的包,点击进入下载页 installpywhl.png

,选择相应的版本(如cp38表示python 3.8版本)点击下载即可。

下载完成后,在cmd窗口输入pip3 install 安装包地址即可执行安装。(在虚拟环境装需要先切换到虚拟环境)

之后重新安装apache-superset,安装完成。

Superset初次使用

先进入Superset 安装目录( ...\Anaconda3\envs\superset\Lib\site-packages\superset\bin )。然后运行如下命令

一、创建管理员用户

声明变量

set FLASK_APP=superset

创建用户

flask fab create-admin

说明:flask是一个python web框架,Supperset使用的就是flask

二、初始化数据库

python superset db upgrade

三、载入案例数据

不影响使用可以跳过

python superset load_examples

四、初始化角色与权限

python superset init

五、启动服务

python superset run -h 127.0.0.1 -p 9988 --with-threads

  • -h 指定ip;-p 指定端口

访问localhost:9988,出现登录页面,安装成功

其它

  • 设置中文

    打开 ..\Anaconda\envs\superset\Lib\site-packages\superset下的config.py文件 搜索language设置 BABEL_DEFAULT_LOCALE = "zh"