[TOC]
安裝ipython
pass
編輯ipython的配置文件
執(zhí)行
ipython profile create pyspark
創(chuàng)建~/.ipython/profile_pyspark
編輯~/.ipython/profile_pyspark/ipython_notebook_config.py
c = get_config()
c.NotebookApp.ip = '*' # or 127.0.0.1 or local ip
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8880 # whatever you want;be ware of confilcts
編輯
~/.ipython/profile_pyspark/startup/00-pyspark-setup.py
import os
import sys
spark_home = os.environ.get('SPARK_HOME', None)
if not spark_home:
raise ValueError('SPARK_HOME environment variable is not set')
sys.path.insert(0, os.path.join(spark_home, 'python'))
sys.path.insert(0, os.path.join(spark_home, 'python/lib/py4j-0.8.1-src.zip'))
execfile(os.path.join(spark_home, 'python/pyspark/shell.py'))
申明變量
第一行是讓pyspark走ipython杭攻,第二行是讓ipython用notebook疤坝,第三行是指定sparkhome,最后一行可以不寫
export IPYTHON=1
export IPYTHON_OPTS="notebook --pylab inline"
export SPARK_HOME='/home/leisurem/cm/spark-1.6.1-bin-hadoop2.6'
#export PYSPARK_SUBMIT_ARGS='--master yarn --deploy-mode client --num-executors 24 --executor-memory 4g --executor-cores 2'
執(zhí)行pyspark
ipython notebook --profile=pyspark
如果執(zhí)行
./pyspark
這個會用默認(rèn)的profile锅睛,也就是profile_default历谍,把剛才修改的/.ipython/profile_pyspark/ipython_notebook_config.py拷貝到/.ipython/profile_default即可
要顯示行數(shù),在notebook里按ctrl+m進(jìn)入到命令行模式印蔬,按l就好了,再按esc退出