weget 下载指定的Python版本
weget Index of /ftp/python/3.6.8/
一、安装依赖
yum -y groupinstall "Development tools"
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
二、安装Python3
[root@localhost ~]# mkdir /usr/local/python3
[root@python3]# cd Python-3.6.7/
[root@Python-3.6.7]# ./configure prefix=/usr/local/python3 --enable-optimizations
[root@Python-3.6.7]# make && make install
三、简历软连接
[root@localhost ~] ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@localhost ~] ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
四、异常
问题一:安装时报错ModuleNotFoundError: No module named '_ctypes'的解决办法
1、执行如下命令:
yum install libffi-devel
2、从"./configure ..."重新安装
五、更新pip
当线上有pip和pip3 时
pip3 install --upgrade pip
python3 -m pip install --upgrade pip
三、高版本centerOS安装高版本Python
下载指定python版本 wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2rc2.tgz 解压 tar -zxvf Python-3.8.2rc2.tgz cd Python-3.8.2 ./configure prefix=/usr/local/python3 --enable-optimizations make && make install 报错 zipimport.ZipImportError: can't decompress data; zlib not available yum -y install zlib* 重新编译安装 替换python3 版本 mv /usr/bin/python3 /usr/bin/python36 mv /usr/bin/pip3 /usr/bin/pip36 ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3 ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3 pip3 install --upgrade pip