Open dalaolala opened 4 years ago
1、下载安装包
https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
3、配置安装环境
#否则将会提示No module named‘_ctypes’
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install -y libffi-devel zlib1g-dev
yum install zlib* -y
yum -y install gcc
yum -y groupinstall "Development tools"
4、编译安装python
tar xvf Python-3.7.0.tar
cd Python-3.7.0
./configure --prefix=/usr/local/python3.7/ --enable-optimizations
make && make install
5、设置默认python
ln -s /usr/local/python3.7/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3.7/bin/pip3.7 /usr/bin/pip3
wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz
配置安装环境
#否则将会提示No module named‘_ctypes’
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
yum install -y libffi-devel zlib1g-dev
yum install zlib* -y
yum -y install gcc
yum -y groupinstall "Development tools"
解压安装
# 解压压缩包
tar -zxvf Python-3.8.1.tgz
# 进入文件夹
cd Python-3.8.1
# 配置安装位置
./configure prefix=/usr/local/python3
# 安装
make && make install
添加软链接
#添加python3的软链接
ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
#添加 pip3 的软链接
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
./configure --prefix=/usr/local/python3.7/
Centos 7 自带Python2.7.5版本。而默认的 YUM 安装的python3是 3.6版本,遂升级到3.8版本
# 仓库注册
yum install -y centos-release-scl
# 安装python3.8
yum install -y rh-python38 which
创建软链接
ln -s /opt/rh/rh-python38/root/usr/bin/python3 /usr/bin/python3
ln -s /opt/rh/rh-python38/root/usr/bin/pip3 /usr/bin/pip3
目前python2已经完全不更新了 而且会莫名其妙出现各种各样的问题
下面是升级到python3的方法
1、手动安装
提示没有gcc,则要先安装一下
如果提示出现 'Ignoring ensurepip failure: pip 7.1.2 requires SSL/TLS'
2、使用一键脚本安装
参考这里:https://github.com/Jrohy/python3-install