Ubuntu16.04安装pyspark报错Make sure that you use the correctversion of ‘pip‘ installed for your Python

ubuntu16.04安装完成以后自带的python版本是2.7和3.5,系统默认使用的是2.7版本。然而在使用过程中可能需要python3.5以上的版本,这就需要进行python版本的切换。
比如我这次实验过程中需要python3.5/3.6版本,在默认情况使用2.7版本时,在pycharm中安装第三方库pyspark时失败并报如下错误:
Try to run this command from the system terminal.Make sure that you use the correctversion of ‘pip’ installed for your Python interpreter located at’/home/hadoop/PycharmProjects/WordCount/venv/bin/python’.
Ubuntu16.04安装pyspark报错Make sure that you use the correctversion of ‘pip‘ installed for your Python_第1张图片

切换python版本:

(1)查看系统中所有的python版本和安装路径

whereis python

在这里插入图片描述ubuntu16.04默认自带python2.7和3.5两个版本

(2)查看当前默认使用的python版本

python

在这里插入图片描述当前默认使用3.5版本,然后exit()退出

(3)添加需要的python版本到可选列表

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2

注意ubuntu16.04默认的python路径是/usr/bin/python2.7和/usr/bin/python3.5,具体根据自己的实际情况更改路径。最后的数字是可选列表的顺序。

(4)查看可选列表,切换python版本
查看可选列表:

update-alternatives --list python

在这里插入图片描述
切换python版本:

sudo update-alternatives --config python

Ubuntu16.04安装pyspark报错Make sure that you use the correctversion of ‘pip‘ installed for your Python_第2张图片
查看切换完成的python版本:

python

在这里插入图片描述

安装pip3和第三方库pyspark

(1)在终端安装pip3

sudo apt install python3-pip

在这里插入图片描述
(2)查看安装结果

 pip3 --version

在这里插入图片描述
证明pip3关联到python3.5版本
(3)安装pyspark
启动pycharm:

pycharm.sh

在你的工程下面>File>Settings…
Ubuntu16.04安装pyspark报错Make sure that you use the correctversion of ‘pip‘ installed for your Python_第3张图片
Ubuntu16.04安装pyspark报错Make sure that you use the correctversion of ‘pip‘ installed for your Python_第4张图片
Ubuntu16.04安装pyspark报错Make sure that you use the correctversion of ‘pip‘ installed for your Python_第5张图片
安装过程比较漫长10min–40min甚至更久…
安装成功以后会出现“successfully”字样,到此问题就解决啦~

python版本切换参考:
[https://blog.csdn.net/zbr794866300/article/details/107076824?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165175441416780366595778%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=165175441416780366595778&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2allfirst_rank_ecpm_v1~rank_v31_ecpm-1-107076824.142v9pc_search_result_cache,157v4control&utm_term=ubuntu%E6%9B%B4%E6%8D%A2python%E7%89%88%E6%9C%AC&spm=1018.2226.3001.4187]

你可能感兴趣的:(spark,python,pycharm,开发语言)