镜像:CentOS Linux release 8.5.0-13
python下载地址:Python Source Releases | Python.org
选择所需要的版本,我这里最新版本是3.10.0
第一步:安装依赖包
yum install -y gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel xz-devel libffi-devel
第二步:编译安装python
[root@192 ~]# cd /opt/ [root@192 opt]# wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz [root@192 opt]# tar xf Python-3.10.0.tgz [root@192 opt]# cd Python-3.10.0/ [root@192 Python-3.10.0]# ./configure --prefix=/usr/local/python --enable-optimizations [root@192 Python-3.10.0]# make && make install
第三步:配置全局环境
[root@192 ~]# echo 'export PATH=$PATH:/usr/local/python/bin/' >> /etc/profile [root@192 ~]# source /etc/profile [root@192 ~]# python3 -V Python 3.10.0
转载于:https://blog.csdn.net/Cookie_1030/article/details/121370340
原创文章,作者:506227337,如若转载,请注明出处:https://blog.ytso.com/270930.html