一,查看现有的版本:
1,本地版本
[root@img ~]# python --version
Python 3.9.16
2,现在的最新版本:
访问官网:
https://www.python.org/
如图:
可以看到线上的最新版本是3.11.4
二,编译/安装:
1,下载:
先复制下载地址
2,从服务器用wget命令下载:
[root@img python]# wget https://www.python.org/ftp/python/3.11.4/Python-3.11.4.tgz
3,下载完成后解压缩:
[root@img python]# tar -zxvf Python-3.11.4.tgz
4,配置
[root@img python]# cd Python-3.11.4/
[root@img Python-3.11.4]# ./configure --prefix=/usr/local/soft/python3.11.4 --enable-optimizations
5,编译
[root@img Python-3.11.4]# make
6,安装
[root@img Python-3.11.4]# make install
7,安装完成后查看效果:
[root@img Python-3.11.4]# /usr/local/soft/python3.11.4/bin/python3 --version
Python 3.11.4
[root@img Python-3.11.4]# /usr/local/soft/python3.11.4/bin/pip3 --version
pip 23.1.2 from /usr/local/soft/python3.11.4/lib/python3.11/site-packages/pip (python 3.11)
说明:刘宏缔的架构森林—专注it技术的博客,
网站:https://blog.imgtouch.com
原文: https://blog.imgtouch.com/index.php/2023/08/02/rocky-linux-bian-yi-an-zhuang-python3-11-4-rocky-linux-9-2/
代码: https://github.com/liuhongdi/ 或 https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: [email protected]
三,替换原有的python和pip
1,查看原有的python和pip所在的路径
[root@img Python-3.11.4]# whereis python3
python3: /usr/bin/python3 /usr/share/man/man1/python3.1.gz
[root@img Python-3.11.4]# whereis pip3
pip3: /usr/bin/pip3
2,创建python3的符号链接
[root@img Python-3.11.4]# mv /usr/bin/python3 /usr/bin/python3.bak
[root@img Python-3.11.4]# ln -s /usr/local/soft/python3.11.4/bin/python3 /usr/bin/python3
[root@img Python-3.11.4]# python --version
Python 3.11.4
3,创建pip3的符号链接
[root@img Python-3.11.4]# mv /usr/bin/pip3 /usr/bin/pip3.bak
[root@img Python-3.11.4]# ln -s /usr/local/soft/python3.11.4/bin/pip3 /usr/bin/pip3
[root@img Python-3.11.4]# pip --version
pip 23.1.2 from /usr/local/soft/python3.11.4/lib/python3.11/site-packages/pip (python 3.11)
四,查看linux的版本:
[[email protected]]# cat/etc/redhat-release
Rocky Linuxrelease9.2(Blue Onyx)
标签:python3.11,rocky,img,Python,3.11,python,usr,linux,root
From: https://www.cnblogs.com/architectforest/p/17616165.html