Spark实战(三)本地连接远程Spark(Python环境)

一、Python环境准备

   远程服务器上Python版本要与本地想匹配,这里本地使用Anaconda来进行安装,远程服务器之间安装。

wget --no-check-certificate https://www.python.org/ftp/python/3.6.7/Python-3.6.7.tgz
tar -zxvf Python-3.6.7.tgz 
sudo ./configure --prefix=/usr/local/python3
make & make install
建立软连接
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python

   本地之间下载Anaconda安装包,会自动安装相关环境。

二、配置PyCharm

   在file->setting->project interpreter中新增一个python环境,

在这里插入图片描述

在这里插入图片描述
   tool->Deployment->Configuration中新建一个SFTP

在这里插入图片描述

在这里插入图片描述
   Mappings中Local path路径正斜杠要修改一下改为反斜杠,否则可能会无法识别导致报错
在这里插入图片描述

    接下来需要在configuration中更改运行参数

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
   因为是远程环境,Environment Variables中需要指明服务器端python路径,spark路径,java路径。

   在file->setting->project interpreter下载安装py4j,pyspark等包,否则会报错

在这里插入图片描述

   以下是配置中遇到的一些常见错误:

在这里插入图片描述
   去上面搜索安装pyspark-stubs

在这里插入图片描述
    上面错误表示py4j版本不兼容,重新下载想匹配的版本

在这里插入图片描述
   spark FileNotFoundError: [WinError 2] 系统找不到指定的文件,需要查询edit configuration中python interpreter是否选择正确

   python3安装完成后默认没有安装pip,需要自己去安装,否则会出先pip未找到的错误

备份原来的源:输入命令sudo cp /etc/apt/sources.list /etc/apt/sources_init.list
输入命令sudo vi /etc/apt/sources.list
添加如下
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse  
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse  
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse 

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python3-pip
sudo apt-get install python-pip
  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值