Python安装
(1) 前置安装spark
(2) 在/etc/profile配置spark环境
#spark environment
export SPARK_HOME=/opt/soft/spark234
export SPARK_CONF_DIR=$SPARK_HOME/conf
export PATH=$PATH:$SPARK_HOME/bin
(3) 安装bzip2
[root@zjw ~]# yum install -y bzip2
(此步不执行安装anaconda会报错)
(4) 直接执行下载到linux下的Anaconda3-5.1.0-Linux-x86_64.sh文件
bash Anaconda3-5.1.0-Linux-x86_64.sh
根据提示回车或yes 只有最后安装vcode回答no
(5) 生成jupyter配置文件
(我使用root用户路径是/root/.jupyter/jupyter_notebook_config.py
)
进入你的用户目录
[root@zjw ~]# cd /root/anaconda3/bin/
[root@zjw bin]# ./jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
(6) 生成Jupyter登录密码
[root@zjw bin]# ./ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:0a3a43e3c8b5:c0791ceb50721d9475ae53760b3d7e66b0217ebd'
In [3]: quit()
输入你的密码后 生成一个sha1:xxxxx 用记事本链贴好
(7) 修改jupyter_notebook_config.py文件
[root@zjw bin]# cd /root/.jupyter/
[root@zjw .jupyter]# vi jupyter_notebook_config.py
c.NotebookApp.allow_root=True
c.NotebookApp.ip='*'
c.NotebookApp.open_browser=False
c.NotebookApp.password=u'刚才生成的密码'
c.NotebookApp.port=7070 #此端口为不使用pyspark的端口
(8) 配置环境变量/etc/profile 并激活
[root@zjw .jupyter]# vi /etc/profile
[root@zjw .jupyter]# source /etc/profile
环境变量:
#anaconda3 environment
export ANACONDA_HOME=/root/anaconda3
export PATH=$PATH:$ANACONDA_HOME/bin
export PYSPARK_DRIVER_PYTHON=jupyter-notebook
export PYSPARK_DRIVER_PYTHON_OPTS=" --ip=0.0.0.0 --port=8888"
(9) 执行命令
-
如果要环境加入pyspark 就直接执行命令
pyspark
-
如果只需要普通python环境 就输入命令
jupyter notebook --allow-root
[root@zjw .jupyter]# jupyter notebook --allow-root
[I 17:43:21.048 NotebookApp] Writing notebook server cookie secret to /run/user/0/jupyter/notebook_cookie_secret
[W 17:43:21.358 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 17:43:21.382 NotebookApp] JupyterLab beta preview extension loaded from /root/anaconda3/lib/python3.6/site-packages/jupyterlab
[I 17:43:21.382 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[I 17:43:21.385 NotebookApp] Serving notebooks from local directory: /root/.jupyter
[I 17:43:21.385 NotebookApp] 0 active kernels
[I 17:43:21.385 NotebookApp] The Jupyter Notebook is running at:
[I 17:43:21.385 NotebookApp] http://[all ip addresses on your system]:7070/
[I 17:43:21.385 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
(10) 再浏览器上根据命令提示的端口登录
ip地址加上7070端口