文章目录
- 环境准备
- 1 安装依赖项
- python源码准备
- 编译
- 验证
- 配置环境变量(可选)
环境准备
1 安装依赖项
sudo yum update -y sudo yum groupinstall -y "Development Tools" sudo yum install -y \ gcc \ openssl-devel \ bzip2-devel \ libffi-devel \ zlib-devel \ wget sudo yum install -y centos-release-scl sudo yum install -y devtoolset-10 scl enable devtoolset-10 bash echo "source /opt/rh/devtoolset-10/enable" >> ~/.bashrc source ~/.bashrc
python源码准备
cd /usr/src sudo wget https://www.python.org/ftp/python/3.12.3/Python-3.12.3.tgz sudo tar xzf Python-3.12.3.tgz cd Python-3.12.3
编译
sudo mkdir -p /data/opt/python/python3 sudo ./configure --prefix=/data/opt/python/python3 --enable-optimizations sudo make altinstall wget https://bootstrap.pypa.io/get-pip.py sudo /data/opt/python/python3/bin/python3.12 get-pip.py
验证
/data/opt/python/python3/bin/python3.12 --version /data/opt/python/python3/bin/pip3.12 --version
配置环境变量(可选)
sudo vim /etc/profile # Set PATH for Python 3.12 installation export PATH="/usr/local/bin/python3.12:$PATH" # 保存并关闭文件,然后使更改生效: source /etc/profile ln -s xxx xxx
还没有评论,来说两句吧...