如下操做只需在部署Zeppelin的服務器下便可html
一、https://www.continuum.io/downloads 下載anacondapython
二、安裝,我下載的是linux版本的python2.7,安裝過程簡單,我安裝在了/usr/local/anaconda2下linux
三、替換系統的python版本,個人是python2.6,你們能夠在/usr/bin/下看python的版本,我是python2.6,因此shell
mv /usr/bin/python /usr/bin/python2.6 ln -s /usr/local/anaconda2/bin/python2.7 /usr/bin/python
四、在/conf/zeppelin-env.sh中添加服務器
export PYSPARK_PYTHON=/home/spark-1.6.0-bin-hadoop2.6/pythondom
export PYTHONPATH=/home/spark-1.6.0-bin-hadoop2.6/python:/home/spark-1.6.0-bin-hadoop2.6/python/lib/py4j-0.9-src.zippython2.7
五、編輯/etc/profile,添加svg
export PYTHONPATH=/home/spark-1.6.0-bin-hadoop2.6/python://home/spark-1.6.0-bin- hadoop2.6/python/lib/py4j-0.9-src.zipoop
六、啓動並打開zeppelin的interpreter,在spark的interpreter添加spark.home
spa
修改zeppelin.pyspark.python(若是不執行第3步,直接在此處填寫anaconda的安裝目錄是不行的)
七、執行conda install matplotlib(默認包含了matplotlib能夠不用執行,不存在的包能夠這樣執行)
八、新建notebook
%pyspark #這兩行必須在最前 import matplotlib matplotlib.use('Agg') import numpy as np import matplotlib.mlab as mlab import matplotlib.pyplot as plt import StringIO #這是必須的,不然圖表不顯示 def show(p): img = StringIO.StringIO() p.savefig(img, format='svg') img.seek(0) print "%html <div style='width:600px'>" + img.buf + "</div>" mu = 100 sigma = 15 x = mu + sigma * np.random.randn(10000) num_bins = 50 n, bins, patches = plt.hist(x, num_bins, normed=1, facecolor='green', alpha=0.5) y = mlab.normpdf(bins, mu, sigma) plt.plot(bins, y, 'r--') plt.xlabel('Smarts') plt.ylabel('Probability') plt.title(r'Histogram of IQ: $\mu=100$, $\sigma=15$') plt.subplots_adjust(left=0.15) show(plt)