
创建项目目录
我这里是在windows系统下进行部署, 创建 G:\myPython\superset\文件夹
切换到命令行,进入该文件夹。
创建虚拟环境
virtualenv superset
创建一个虚拟环境,因为superset依赖库众多,担心和其他项目出现依赖冲突,所以在虚拟环境中进行部署
superset\Scripts\activate
激活刚才创建的虚拟环境
pip install apache_superset
安装apache_superset 如果速度慢,也可以使用国内镜像源
pip install apache_superset -i https://mirrors.aliyun.com/pypi/simple/
初始化superset数据库
superset db upgrade

错误提示: "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."
执行一下set FLASK_APP=superset
即可

提示使用了默认的SECRET_KEY,需要在G:\myPython\superset\superset\Lib\site-packages\superset\config.py文件里面进行改写,并提示使用openssl rand -base64 42
命令生成。
由于我的电脑没有安装openssl库,所以到slproweb.com/products/Wi...:
下载并安装。
生成SECRET_KEY,并修改config.py文件:

继续执行:superset db upgrade
出现TypeError,调用marshmallow库时候出现了不应该出现的关键字参数。
直觉感觉是marshmallow库版本的问题,查看安装superset的时候安装的marshmallow库版本是4.0.0 先删除:pip uninstall marshmallow

先使用一个不存在的版本号,查看可以通过pip安装的版本号:
可以看到4.0.0是最新的版本,且是大版本升级。试着安装低版本的:

继续执行:superset db upgrade
这次终于正常了。

创建登录账号
superset fab create-admin

加载用例数据
superset load_examples

初始化角色和权限
superset init

启动superset
superset run -p 8088 --with-threads --reload --debugger

打开http://127.0.0.1:8088/即可访问,使用创建的管理员即可登录成功。
登录后发现界面一直在加载中,查看命令行superset有WARNING信息: Unable to load SQLAlchemy dialect shillelagh.multicorn2: No module named 'psycopg2'

pip install psycopg2
安装模块
修改默认语言

请注意,开发 Web 服务器(通过 superset run
或 flask run
运行)并不适用于生产环境使用。 你可以在 NGINX 或 Apache 上运行 Superset,但推荐使用 Gunicorn 的异步模式。
pip install gunicorn
gunicorn --workers 5 --timeout 120 --bind 0.0.0.0:8787 "superset.app:create_app()" --daemon
执行后报错: 提示没有模块'fcntl'
原因
fcntl docs.python.org/3/library/f... 为python标准库中的一个模块,属于Unix Specific,负责操作文件锁,当使用python进行写文件时,如果多个进程同时写同一个文件,那么可能会存在问题,fcntl就是用来避免这个问题,使用系统锁的机制来保证同时只有一个进程写文件。很显然,这个模块是为linux系统准备,windows python中是不自带的,所以当我们在windows中运行使用了fcntl模块的py时,就会报错,模块无法找到。通过mock一个假的fcntl.py放到python库中即可。
python
#新建fcntl.py
def fcntl(fd, op, arg=0):
return 0
def ioctl(fd, op, arg=0, mutable_flag=True):
if mutable_flag:
return 0
else:
return ""
def flock(fd, op):
return
def lockf(fd, operation, length=0, start=0, whence=0):
return