IPython Notebook 運行python Spark程序
阿新 • • 發佈:2018-09-04
com swd div passwd open bashrc 配置文件 das ner
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
IPython Notebook 運行python Spark程序