1、 使用源码编译安装:您可以从Python官方网站下载Python 3.9的源代码,并按照以下步骤进行编译和安装:
- 安装编译所需的依赖项:
sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel readline-devel sqlite-devel
- 下载Python 3.9的源代码包:
wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
- 解压源代码包:
tar xzf Python-3.9.9.tgz
- 进入解压后的目录:
cd Python-3.9.9
- 配置、编译和安装Python:
./configure --enable-optimizations make sudo make altinstall
- 将Python 3.9添加到系统环境变量:
#按照下面的每一步进行操作
find /usr/local -name "python3.9" vim ~/.bash_profile
#将此2行内容进行复制粘贴到bash_profile中 export PATH="/usr/local/bin:$PATH" alias python="/usr/local/bin/python3.9"
#保存让文件生效 source ~/.bash_profile
- 验证Python3.9环境
python3.9 --version 或者python --version
标签:源代码,Python,devel,Centos7,python,Python3.9,安装,3.9 From: https://www.cnblogs.com/syw20170419/p/17427218.html