1、pip流
裝了pip可以無視步驟2,但是專業人士一般會使用Anaconda
1.1、裝pip
https://pip.pypa.io/en/stable/installing/
懶得看就直接:
a)wgethttps://bootstrap.pypa.io/get-pip.py
b)sudo python get-pip.py
1.2、裝virtualenv
http://qicheng0211.blog.51cto.com/3958621/1561685
懶得看就直接:
a)sudo pip install virtualenv
b)sudo pip install virtualenvwrapper
c)給自己~/.profile里加上
export WORKON_HOME=~/{自己起個名放workspace}
source /usr/bin/virtualenvwrapper.sh #如果是pip下來的一般會在/usr/local/bin/virtualenvwrapper.sh,總之自己找一下
d)mkvirtualenv superset
2、Anaconda流
2.1、裝Anaconda
a)官網下一個https://www.anaconda.com/download/#linux,500多M,覺得慢可以到小伙伴那里抓一個過來
b)不用sudo,bash?Anaconda2-*******.sh
c)一路回車,默認會裝在~/anaconda2目錄下,如果想裝在別的地方,在看完那個巨長的一定要看但是肯定沒人看的用戶協議之后,輸入安裝目錄
d)把anaconda2/bin加到你的PATH里
e)更新一下自己conda upgrade --all
做完上一步,你一定發現下包速度很慢了,按下面的來
# 添加Anaconda的TUNA鏡像
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
# TUNA的help中鏡像地址加有引號,需要去掉
# 設置搜索時顯示通道地址
conda config --set show_channel_urls yes
2.2、配個環境
其實anaconda自帶切環境功能,
conda create -n {env_name}
source activate?{env_name}
conda install pip
更多操作看這里http://www.lxweimin.com/p/169403f7e40c
3、裝superset
https://superset.incubator.apache.org/installation.html
懶得看就直接:
寫作“注意”,讀作“坑”:如果你先裝的pip,后裝的anaconda,使用pip install superset的時候,使用pip -V看一下你使用的是系統默認的pip還是虛擬環境中的pip
a)刷一下pip install --upgrade setuptools pip
b)官方教你走一下這個流程
# Install supersetpipinstallsuperset
# Create an admin user (you will be prompted to set username, first and last name before setting a password)fabmanagercreate-admin--appsuperset# Initialize the databasesupersetdbupgrade# Load some data to play withsupersetload_examples# Create default roles and permissionssupersetinit# Start the web server on port 8088, use -p to bind to another portsupersetrunserver# To start a development web server, use the -d switch# superset runserver -d
以下是贈品
4、打通superset與kylin
4.1、安裝pykylin
a)照著做:https://github.com/imaidata/pykylin
b)python setup.py install的時候可能會報README找不到,在setup.py里找到readme相關的兩行代碼注釋之
b)在superset中添加數據源,source?→ databases?→ add record 然后這么填
kylin://{此處是賬號}:{此處是密碼}@{url}:{port}/kylin/api?project={project}
c)點test connection,等出現seems ok, 不過一般來說會報flask_wtf.csrf: The CSRF?token has expired
一般來說這是缺少flask包導致的,conda install flask或者pip install flask
4.1、改pykylin源碼
由于pykylin的代碼已經比較陳舊,跟不上superset和kylin的更新
本次修改基于如下版本,不保證其他版本有效
superset:0.20.4
apache kylin:release 2.1
pykylin:https://github.com/imaidata/pykylin/commits/mastercommit9f5f2d7218f76b35c76a3bc3de22db4cbe09f61d
a) 添加table的時候會報get_table_names參數個數不對,修改pykylin的dialect.py,找到get_table_names和get_schema_names兩個方法,將3個參數擴充為四個,姑且叫做unknown=None,如下圖:
b) count是kylin關鍵字,pykylin會將sql中的count替換為'__superset_count',但返回時未替換回來,所以需要修改cursor.py的execute方法。62行65行