centos7 安装python3

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
make && make install

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

 

 

参考文章:

https://blog.csdn.net/u014749862/article/details/54430022

https://blog.csdn.net/qq_36416904/article/details/79316972

https://blog.csdn.net/u012804180/article/details/79081424

https://blog.csdn.net/win_turn/article/details/51585194

你可能感兴趣的:(运维,linux)