cetnos7 默认安装python2,python3 需要手动安装
1 .官网下载python3 安装包
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
2 解压安装包
-
xz -d Python-3.7.3.tar.xz
-
tar -xf Python-3.7.3.tar
3.进入解压目录,编译
-
cd Python-3.7.3
-
./configure prefix=/usr/local/python3 --with-ssl 或者./configure --prefix=/usr/local/python3 --enable-optimizations
-
make && make install或者
make
make altinstall
4 创建软链接
-
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
-
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
5.测试
python3 --version
编译中(第3步)遇到问题及解决方法
1 no acceptable C compiler found in $PATH
yum install -y gcc
2 zipimport.ZipImportError: can't decompress data
yum -y install zlib*
3 ModuleNotFoundError: No module named '_ctypes'
yum install libffi-devel -y