[TOC]
安装ipython
pass
编辑ipython的配置文件
执行
ipython profile create pyspark
创建~/.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'
执行pyspark
ipython notebook --profile=pyspark
如果执行
./pyspark
这个会用默认的profile,也就是profile_default,把刚才修改的/.ipython/profile_pyspark/ipython_notebook_config.py拷贝到/.ipython/profile_default即可
要显示行数,在notebook里按ctrl+m进入到命令行模式,按l就好了,再按esc退出