安裝 superset
創建虛擬環境:
python -m venv msuperset
激活虛擬環境:
cd msuperset
source bin/activate
安裝 superset
pip install superset
如果遇到報錯:
Running setup.py install for python-geohash ... error
Complete output from command /root/code/python/msuperset/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-szdbf0qe/python-geohash/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-omybv2pz-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/code/python/msuperset/include/site/python3.6/python-geohash:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
copying geohash.py -> build/lib.linux-x86_64-3.6
copying quadtree.py -> build/lib.linux-x86_64-3.6
copying jpgrid.py -> build/lib.linux-x86_64-3.6
copying jpiarea.py -> build/lib.linux-x86_64-3.6
running build_ext
building '_geohash' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/src
gcc -pthread -B /root/miniconda3/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DPYTHON_MODULE=1 -I/root/code/python/msuperset/include -I/root/miniconda3/include/python3.6m -c src/geohash.cpp -o build/temp.linux-x86_64-3.6/src/geohash.o
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/root/code/python/msuperset/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-szdbf0qe/python-geohash/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-omybv2pz-record/install-record.txt --single-version-externally-managed --compile --install-headers /root/code/python/msuperset/include/site/python3.6/python-geohash" failed with error code 1 in /tmp/pip-build-szdbf0qe/python-geohash/
需要安裝 gcc-c++
:
yum install gcc-c++
裝完 gcc-c++
后,再執行 pip install superset
應該就沒問題了。
配置 superset
創建管理員用戶
fabmanager create-admin --app superset
執行的時候會有這么一行提示:
fabmanager is going to be deprecated in 2.2.X, you can use the same commands on the improved 'flask fab <command>'
這是一個新的用法了,還沒有研究
接着會讓你輸入用戶名(username)、Fist Name、Last Name、郵箱地址、密碼、重復密碼。
如果遇到以下錯誤:
Was unable to import superset Error: cannot import name '_maybe_box_datetimelike'
原因是 pandas
(在安裝 superset
時會做為依賴被安裝上)版本太高,需要卸載,再安裝低版本的 pandas
。
pip install pandas==0.23.4
參考https://blog.csdn.net/kongxx/article/details/89006787
然后重新執行創建管理員用戶的命令:
fabmanager create-admin --app superset
初始化數據庫
superset db upgrade
如果遇到錯誤:
...
File "/root/code/python/msuperset/lib/python3.6/site-packages/sqlalchemy/orm/query.py", line 2572, in _join_determine_implicit_left_side
"Can't determine which FROM clause to join "
sqlalchemy.exc.InvalidRequestError: Can't determine which FROM clause to join from, there are multiple FROMS which can join to this entity. Try adding an explicit ON clause to help resolve the ambiguity.
說明 sqlalchemy
版本太高了,要降級 sqlalchemy
:
pip install sqlalchemy==1.2.18
參考https://github.com/apache/incubator-superset/issues/6977
載入測試數據
superset load_examples
初始化角色和權限
superset init
啟動服務
端口號 8088,使用 -p 更改端口號
superset runserver
然后在瀏覽器中打開 http://localhsot:8088 就可以看到 superset 了
添加 mysql 數據源時出錯
提示
ModuleNotFoundError: No module named 'MySQLdb'
因為 MySQLdb 是 python2 的產品。可使用 mysqlclient 方式代替。要安裝 mysqlclient
:
先安裝需要用到的系統依賴:
Ubuntu
下:
sudo apt-get install python3-dev libmysqlclient-dev
CentOS
下:
yum install python-devel mysql-devel
然后安裝 mysqlclient
:
pip install mysqlclient
其它錯誤
...
In file included from sasl/saslwrapper.cpp:254:0:
sasl/saslwrapper.h:22:10: fatal error: sasl/sasl.h: No such file or directory
#include <sasl/sasl.h>
^~~~~~~~~~~~~
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
安裝 libsasl2-dev
ubuntu
apt-get install libsasl2-dev
centos
yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-lib
其它操作參考:
輕量級BI工具Superset的搭建與使用
官方安裝說明