CentOS7升级python2到python3



安装依赖

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc  libffi-devel

下载 解压

wget  https://www.python.org/ftp/python/3.9.2/Python-3.9.2.tgz
tar -zxf tar -zxf Python-3.9.2.tgz
cd Python-3.9.2

编译

cd /usr/local/
mkdir python3
cd python3/
./configure
make
make install

备份python2

mv /usr/bin/python /usr/bin/python.bak

创建新的软连接

ln -s /usr/local/bin/python3.9 /usr/bin/python

更改yum配置,因为yum要使用python2

vim /usr/bin/yum
vim /usr/libexec/urlgrabber-ext-down

将这两个文件头的 #!/usr/bin/python 改为 #!/usr/bin/python2

标签: python3

相关文章

评论已关闭