centos

CentOS Python安装步骤

小樊
50
2025-08-12 22:46:06
栏目: 编程语言

以下是在CentOS上安装Python的步骤:

一、安装依赖

sudo yum groupinstall "Development Tools" -y
sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel readline-devel sqlite-devel tk-devel wget make -y

二、下载Python源码

cd /usr/src
sudo wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tgz  # 替换为最新版本号
sudo tar xzf Python-3.x.x.tgz
cd Python-3.x.x

三、编译安装

sudo ./configure --enable-optimizations --prefix=/usr/local/python3.x  # 指定安装路径
sudo make altinstall  # 使用altinstall避免覆盖系统默认Python

四、配置软链接(可选)

sudo ln -sf /usr/local/python3.x/bin/python3 /usr/bin/python3.x
sudo ln -sf /usr/local/python3.x/bin/pip3 /usr/bin/pip3.x

五、验证安装

python3.x --version
pip3.x --version

其他说明

0
看了该问题的人还看了