superset遠(yuǎn)程調(diào)試手冊:
? 參考資料: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
創(chuàng)建虛擬環(huán)境? python3 -m venv 虛擬環(huán)境路徑(我的虛擬環(huán)境創(chuàng)建命令:python3 -m venv superset-4.1.2/venv)
進(jìn)入虛擬環(huán)境? source superset-4.1.2/venv/bin/active? ? 退出虛擬環(huán)境: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中增加配置項(xiàng)。SECRET_KEY = 'pdMeHXg9ApjTwTj4LETdSpsAVkm2UhH9oY5rvUXzhewRGG7CPD3mzPWL'。superset_config.py的文件位置:superset-4.1.2/docker/pythonpath_dev目錄下
配置環(huán)境變量:SUPERSET_CONFIG_PATH=/mnt/e/ubuntu/superset/superset-4.1.2/docker/pythonpath_dev/superset_config.py(這是解決啟動(dòng)報(bào)沒有SECRET_KEY的錯(cuò)誤)、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 (這個(gè)命令是在虛擬環(huán)境中安裝superset命令)
在venv/bin目錄下執(zhí)行如下命令:
? superset db upgrade? #初始化數(shù)據(jù)庫
? superset fab create-admin #初始化用戶 執(zhí)行過程中需要輸入用戶名密碼
? superset load_examples #加載案例,從github上下載,也可以不執(zhí)行
? superset init #初始化默認(rèn)角色和權(quán)限
啟動(dòng)項(xiàng)目: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? #應(yīng)該輸出"v18.20.8"
? ? nvm current #應(yīng)該輸出"v18.20.8"
? ? npm -v #應(yīng)該輸出"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主界面
本地環(huán)境配置:
Pycharm配置使用遠(yuǎn)程解釋器調(diào)試遠(yuǎn)程代碼_pycharm遠(yuǎn)程調(diào)試后如何退出來使用自己的解釋器呢-CSDN博客?配置pycharm遠(yuǎn)程環(huán)境
配置完以后,在pycharm命令端執(zhí)行命令:python -m venv venv. 將遠(yuǎn)程服務(wù)器中的venv拷貝到本地venv中
配置啟動(dòng)環(huán)境變量:
FLASK_APP=superset
PYTHONUNBUFFERED=1
SUPERSET_CONFIG_PATH=遠(yuǎn)程端superset_config.py文件地址。
錯(cuò)誤:
/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
錯(cuò)誤:
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相關(guān)包先刪除再安裝mysql.再執(zhí)行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是否在環(huán)境變量里,沒有則增加
如果缺少_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文件添加到環(huán)境變量中。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'
解決方法:
因?yàn)槲沂蔷幾g安裝的3.11,但是這個(gè)包在3.6版本里有。#!/usr/bin/python3 改為 #!/usr/bin/python3.6
問題解決連接:
? ? https://www.cnblogs.com/wutou/p/17526402.html