构建虚拟环境

在cmd(管理员模式下)

输入

conda create -n superset python=3.7

激活虚拟环境

C:\Users\23645>activate superset
(superset) C:\Users\23645>

虚拟环境下安装cryptography

(superset) C:Users23645>pip install cryptography

虚拟环境下更新setuptools 和 pip

(superset) C:Users23645>pip install --upgrade setuptools pip

虚拟环境下安装 superset

(superset) C:Users23645>pip install superset

虚拟环境下批量安装包

D盘下新建pacakge.txt,内容如下

flask
wtforms_json
flask_appbuilder
flask_compress
flask_migrate
flask_talisman
flask_caching
email_validator
celery
sqlparse
bleach
markdown
numpy
pandas==0.23.4
pathlib2
simplejson
humanize
polyline
geopy
backoff
pyarrow
croniter
retry
isodate
SQLAlchemy==1.2
parsedatetime
geohash
msgpack
contextlib2
selenium

在cmd(管理员)输入

(superset) C:Users23645>pip install -r D:package.txt -i https://mirrors.aliyun.com/pypi/simple/

升级数据库

记住,上边是一定要在虚拟环境下的C盘中安装,下面升级数据库进入superset下bin中执行。

(superset) C:Users23645>D:

(superset) D:>cd D:softanacondaenvssupersetLibsite-packagessupersetbin

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>python  superset db upgrade

两个修改

  1. 错误:ModuleNotFoundError: No module named 'geohash'

安装后,D:softanacondaenvssupersetLibsite-packages找到Geohash文件夹,改成geohash;找到文件夹里的*init*.py,将文件里的geohash改成.geohash

from .geohash import decode_exactly, decode, encode
  1. D:softanacondaenvssupersetLibsite-packagessuperset下找到config.py,打开将
CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "null"}
TABLE_NAMES_CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "null"}

改成

CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "simple"} TABLE_NAMES_CACHE_CONFIG: CacheConfig = {"CACHE_TYPE": "simple"}

创建管理员账号和密码

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>python superset fab create-admin

INFO:root:logging was configured successfully

Username [admin]: cc
User first name [admin]: cc
User last name [user]: cc
Email [admin@fab.org]: cc@qq.com
Password:
Repeat for confirmation:
Recognized Database Authentications.

载入案例数据(若不成功,则跳过)

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>python superset load-examples

初始化数据库

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>python superset init

启动服务

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>python superset run

结果

INFO:root:logging was configured successfully
 * 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
INFO:werkzeug: * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

打开网页

复制http://127.0.0.1:5000/到浏览器打开网页,输入账号和密码,即可进入。

修改数据库

在cmd 按ctrl + C 退出,安装 pymysql和mysqlclient

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>pip install pymysql

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>pip install mysqlclient

D:softanacondaenvssupersetLibsite-packagessuperset找到config.py,打开将

SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(DATA_DIR, "superset.db")

改成

SQLALCHEMY_DATABASE_URI='mysql+pymysql://root:123456cz@localhost:3306/data?charset=utf8'

然后重新连接superset。

(superset) D:softanacondaenvssupersetLibsite-packagessupersetbin>python superset run