centos安装python3
1、cd /usr/local
sudo yum -y install wget
2、wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
3、tar -xf Python-3.7.2.tar.xz
4、mkdir python3
5、mv Python-3.7.2 python3
6、cd python3
7、./configure --prefix=/usr/local/python3 --enable-optimizations首次报错如下
(
--prefix选项是配置安装的路径,执行后所有资源文件放在/usr/local/python3.6的路径中
)
说明本机中缺少gcc编译环境
那么需要sudo yum install -y gcc
再次运行./configure --prefix=/usr/local/python3 --enable-optimizations
8、make
9、make altinstall
上述错误解决办法:
sudo yum install zlib zlib-devel -y
上述错误解决办法:
sudo yum install libffi-devel -y
再次运行make altinstall
10、安装完成修改软连接
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
11、查看安装版本