liunx上升级python2至python3
作者:互联网
一.背景介绍
虚拟机的liunx系统CentOS7自带了python2.7.5,为使用方便需要换成最新的版本3.10.4
二.安装方法
1.安装升级GCC
yum install -y gcc* openssl openssl-devel ncurses-devel.x86_64 bzip2-devel sqlite-devel zlib python-devel mysql-devel openldap-devel
2.下载python安装包
wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tar.xz
3.解压
tar xvf Python-3.10.4.tar.xz
4.编译安装
cd Python-3.10.4 mkdir -p /usr/local/python3 ./configure --prefix=/usr/local/python3 make && make install
5.将老版本python更换
mv /usr/bin/python /usr/bin/python2.7.5
6.更换默认python
ln -s /usr/local/python3/bin/python3 /usr/bin/python ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip
7.#修改 yum以及urlgrabber-ext-down中的python
将#!/usr/bin/python改为 #!/usr/bin/python2.7.5vim /usr/bin/yum vim /usr/libexec/urlgrabber-ext-downPS:python3.10.4是默认安装pip的,所以不需要另行安装setuptools和pip. 再次查看python版本已经升级:
标签:bin,python,devel,3.10,usr,python2,python3,liunx 来源: https://www.cnblogs.com/mrwhite2020/p/16319331.html