Python——linux环境安装

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) 执行命令

  1. 如果要环境加入pyspark 就直接执行命令 pyspark

  2. 如果只需要普通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端口

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值