notebook软件python_IPython Notebook 运行python Spark程序

1.安装pip

因为centos7.0自带的python系统是2.7.5,并没有安装pip,需要先安装pip

$ wget https://bootstrap.pypa.io/get-pip.py

$ python get-pip.py

$ pip install numpy pandas scipy jupyter

2.配置启动项

$ vim ./.bashrc

export PYSPARK_DRIVER_PYTHON=/usr/bin/ipython

export PYSPARK_PYTHON=/usr/bin/python

$ source ./.bashrc

3.jupyter 无法远程访问

$ jupyter notebook --allow-root

其实这时候,local如果有browser的话,就可以输入访问了,但是没有,所以需要远程访问: http://ip:8888,发现访问不了

(一)配置远程访问jupyter

1)首先输入ipython生成秘钥

$ ipython

from notebook.auth import passwd

passwd()

设定一个密码,会生成一个sha1的秘钥,如下图:

2)生成jupyter的config文件

$ jupyter notebook --generate-config

这时候会生成配置文件,在 ~/.jupyter/jupyter_notebook_config.py

3)修改配置文件:~/.jupyter/jupyter_notebook_config.py

$vim ~/.jupyter/jupyter_notebook_config.py

加入如下内容,其中sha1那一串秘钥是上面生成的那一串

c.NotebookApp.ip='*'

c.NotebookApp.password = u'sha1:f9030dd55bce:75fd7bbaba41be6ff5ac2e811b62354ab55b1f63'

c.NotebookApp.open_browser = False

c.NotebookApp.port =8888

保存退出。

4)启动jupyter

$jupyter notebook --allow-root

在远程电脑上,打开浏览器,输入:

http://your-server-ip:8888

需要输入密码,就是上面设置的那个密码,输入即可

4.本地启动

$ PYSPARK_DRIVER_PYTHON=ipython PYSPARK_DRIVER_PYTHON_OPTS="notebook --allow-root" pyspark # 其中--allow-root是因为root登录master

5.YARN-client模式运行

$ PYSPARK_DRIVER_PYTHON=ipython PYSPARK_DRIVER_PYTHON_OPTS="notebook --allow-root" MASTER=yarn-client pyspark

6.Spark Stand Alone 模式运行

$ /usr/local/spark/sbin/start-all.sh

$ PYSPARK_DRIVER_PYTHON=ipython PYSPARK_DRIVER_PYTHON_OPTS="notebook --allow-root" MASTER=spark://master:7077 pyspark --num-executors 1 --total-executor-cores 2 --executor-memory 512m

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值