##下载链接
wget https://www.python.org/ftp/python/3.10.5/Python-3.10.5.tgz
##安装所需的依赖包
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
##解压
tar -zxf Python-3.10.5.tgz
cd Python-3.10.5/
[root@mylinux7 Python-3.10.5]# ./configure --prefix=/opt/python3
If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations
##忽略
[root@mylinux7 Python-3.10.5]# make
[root@mylinux7 Python-3.10.5]# make install
Installing collected packages: setuptools, pip
WARNING: The scripts pip3 and pip3.10 are installed in '/opt/python3/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-22.0.4 setuptools-58.1.0
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
#查看python版本
[root@mylinux7 Python-3.10.5]# python -V
Python 2.7.5
##编辑环境变量
[root@mylinux7 Python-3.10.5]# vi ~/.bash_profile
export PATH="$PATH:/opt/python3/bin/python"
##建立软链接
which python ##找到路径
cd /usr/bin
rm python
ln -s python3 python
##查看版本
[root@mylinux7 bin]# python -V
Python 3.6.8
标签:Python,python,root,devel,3.10,Linux,##,安装,python3 From: https://www.cnblogs.com/su1999/p/16722983.html