1、查看Linux是否已安装python:ll /usr/bin/pyth*
2、查看当前使用python版本:python --version(Linux一般默认安装python2.7)
3、下载python安装包:wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
4、解压缩 & 进入目录:
tar -zvxf Python-3.8.2
cd Python-3.8.2
5、新建安装目录:mkdir /usr/local/python38
*6、可能会遇到安装目录权限问题:chmod 777 /usr/local/python38
7、安装:./configure --prefix=/usr/local/python38 && make && make install
*8、遇到问题:
configure: error: no acceptable C compiler found in $PATH -----无C编译器
解决:yum -y install gcc --安装C编译器
9、链接:
1)备份:cp /usr/bin/python /usr/bin/python2.bak
2)3.8链接:ln -s /usr/local/python38/bin/python3.8 /usr/bin/python
10、配置pip:ln -s /usr/local/python38/bin/pip3 /usr/bin/pip
*pip -V如无pip命令则配置
11、测试:
1)python测试:python --version
2)pip测试:pip --version
遇到问题:
1、python3.8创建软链接后yum无法使用,解决如下:
1)vi /usr/bin/yum:把 #! /usr/bin/python 修改为 #! /usr/bin/python2
2)vi /usr/libexec/urlgrabber-ext-down:#! /usr/bin/python 修改为#! /usr/bin/python2
2、pip install报错: ModuleNotFoundError: No module named '_ctypes'
yum install libffi-devel -y后,Python-3.8.2安装包下重新编译安装:make install