bashsudo yum install -y openssl-devel bzip2-devel libffi-devel
由于服务器位置在国内, 因此从官方源拉取过慢, 我这里采用阿里镜像源
bashcd /usr/src
wget https://mirrors.aliyun.com/python-release/source/Python-3.12.1.tgz
sudo tar xzf Python-3.12.1.tgz
bashcd /usr/src
sudo wget https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz
sudo tar xzf Python-3.12.1.tgz
bashcd Python-3.12.0
sudo ./configure --enable-optimizations
sudo make altinstall
bashpython3.12 --version
bashsudo /usr/local/bin/python3.12 -m ensurepip sudo /usr/local/bin/python3.12 -m pip install --upgrade pip
bashsudo ln -s /usr/local/bin/python3.12 /usr/bin/python3.12
bashpip3.12 install --upgrade <package-name>
bashsudo alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.12 1
然后选择默认的 Python 版本:
bashsudo alternatives --config python3
本文作者:GYC
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!