superset远程调试手册:
参考资料:https://www.vvave.net/archives/how-to-deploy-apache-superset-on-ubuntu-old-stable.html
https://jishuzhan.net/article/1772571195477069825
编译python源码
下载superset源码。我的版本:4.1.2
创建虚拟环境 python3 -m venv 虚拟环境路径(我的虚拟环境创建命令:python3 -m venv superset-4.1.2/venv)
进入虚拟环境 source superset-4.1.2/venv/bin/active 退出虚拟环境:deactive
安装虚拟依赖包: pip3 install --no-cache -r superset-4.1.2/requirements/development.txt https://pypi.mirrors.ustc.edu.cn/simple/
生成SECRET_KEY 使用命令:openssl rand -base64 42
在superset_config.py中增加配置项。SECRET_KEY = 'pdMeHXg9ApjTwTj4LETdSpsAVkm2UhH9oY5rvUXzhewRGG7CPD3mzPWL'。superset_config.py的文件位置:superset-4.1.2/docker/pythonpath_dev目录下
配置环境变量:SUPERSET_CONFIG_PATH=/mnt/e/ubuntu/superset/superset-4.1.2/docker/pythonpath_dev/superset_config.py(这是解决启动报没有SECRET_KEY的错误)、FLASK_APP=superset
在superset-4.1.2/superset中编写Run.py代码如下:
from app import create_app
if __name__ =='__main__':
app = create_app()
app.run(host="0.0.0.0", port=8088, debug=False)
pip install apache-superset (这个命令是在虚拟环境中安装superset命令)
在venv/bin目录下执行如下命令:
superset db upgrade #初始化数据库
superset fab create-admin #初始化用户 执行过程中需要输入用户名密码
superset load_examples #加载案例,从github上下载,也可以不执行
superset init #初始化默认角色和权限
启动项目:python3 Run.py
编译前端:
在superset-4.1.2/superset-frontend/package-lock.json中找到engines块查看nodejs和npm版本。4.1.2的nodejs版本是18.19.1,npm的版本是10.2.4
安装nodejs和npm。命令如下:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash
\. "$HOME/.nvm/nvm.sh"
nvm install 18
node -v #应该输出"v18.20.8"
nvm current #应该输出"v18.20.8"
npm -v #应该输出"10.8.2"
编译js源码,过程如下:
cd superset-4.1.2/superset-frontend
npm install -g cnpm --registry=https://registry.npmmirror.com
cnpm i puppeteer
export PUPPETEER_SKIP_DOWNLOAD='true'
npm ci
npm run build
完成安装测试:
cd superset-4.1.2/superset
pyton3 Run.py
成功日志如下:
2025-04-18 21:03:26,667:INFO:superset.initialization:Setting database isolation level to READ COMMITTED
* Serving Flask app 'app'
* Debug mode: off
2025-04-18 21:03:48,861:INFO:werkzeug:WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on all addresses (0.0.0.0)
* Running on http://127.0.0.1:8088
* Running on http://172.22.153.82:8088
访问8088端口链接就可以看到superset主界面
本地环境配置:
Pycharm配置使用远程解释器调试远程代码_pycharm远程调试后如何退出来使用自己的解释器呢-CSDN博客 配置pycharm远程环境
配置完以后,在pycharm命令端执行命令:python -m venv venv. 将远程服务器中的venv拷贝到本地venv中
配置启动环境变量:
FLASK_APP=superset
PYTHONUNBUFFERED=1
SUPERSET_CONFIG_PATH=远程端superset_config.py文件地址。
错误:
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 127.
Trying pkg-config --exists libmariadb
Command 'pkg-config --exists libmariadb' returned non-zero exit status 127.
Trying pkg-config --exists perconaserverclient
Command 'pkg-config --exists perconaserverclient' returned non-zero exit status 127.
解决方法:
安装 pkg-config apt-get install pkg-config
错误:
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
Trying pkg-config --exists libmariadb
Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
Traceback (most recent call last):
File "/mnt/e/ubuntu/superset/superset-4.1.2/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
File "/mnt/e/ubuntu/superset/superset-4.1.2/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/e/ubuntu/superset/superset-4.1.2/venv/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 143, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-pelwgb51/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 334, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=[])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-pelwgb51/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-pelwgb51/overlay/lib/python3.11/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
File "<string>", line 155, in <module>
File "<string>", line 49, in get_config_posix
File "<string>", line 28, in find_package_name
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
解决方法:
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config
pip3 install mysqlclient
rmp -qa |grep mariadb 如果有mariadb相关包先删除再安装mysql.再执行1的命令
问题:
creating build/temp.linux-x86_64-cpython-311/Modules
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DHAVE_SASL -DHAVE_TLS -DLDAPMODULE_VERSION=3.4.4 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -I/mnt/e/ubuntu/superset/superset-4.1.2/venv/include -I/usr/local/python3/include/python3.11 -c Modules/LDAPObject.c -o build/temp.linux-x86_64-cpython-311/Modules/LDAPObject.o
In file included from Modules/LDAPObject.c:3:0:
Modules/common.h:15:10: fatal error: lber.h: No such file or directory
#include <lber.h>
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
解决方法:
sudo apt-get install libsasl2-dev python-dev libldap2-dev libssl-dev
sudo apt-get install -y python-dev libldap2-dev libsasl2-dev libssl-dev
echo $PATH 查看gcc是否在环境变量里,没有则增加
如果缺少_bz2,_libsite等库,就需要重新编译安装python.要更新软件源库
问题:
Refusing to start due to insecure SECRET_KEY
解决办法:
在superset_config.py中增加SECRET_KEY的配置:SECRET_KEY = 'pdMeHXg9ApjTwTj4LETdSpsAVkm2UhH9oY5rvUXzhewRGG7CPD3mzPWL'
SECRET_KEY 可以通过 openssl rand -base64 42 命令生成
将superset_config.py文件添加到环境变量中。export SUPERSET_CONFIG_PATH=/mnt/e/ubuntu/superset/superset-4.1.2/docker/pythonpath_dev/superset_config.py
source ~/.baschrc
问题:
Reading package lists... Done
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 25, in <module>
import lsb_release
ModuleNotFoundError: No module named 'lsb_release'
Traceback (most recent call last):
File "/usr/bin/lsb_release", line 25, in <module>
import lsb_release
ModuleNotFoundError: No module named 'lsb_release'
解决方法:
因为我是编译安装的3.11,但是这个包在3.6版本里有。#!/usr/bin/python3 改为 #!/usr/bin/python3.6
问题解决连接:
https://www.cnblogs.com/wutou/p/17526402.html