centos 安装python3.7.5
时间: 2023-10-15 20:21:03 浏览: 84
1. 安装依赖包
```
sudo yum -y update
sudo yum -y groupinstall "Development tools"
sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
```
2. 下载Python 3.7.5源代码
```
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz
```
3. 解压源代码
```
tar -xvf Python-3.7.5.tar.xz
cd Python-3.7.5
```
4. 编译安装Python 3.7.5
```
./configure --prefix=/usr/local/python3
make && make install
```
5. 配置环境变量
```
echo 'export PATH=/usr/local/python3/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
```
6. 验证Python版本
```
python3 -V
```
如果显示Python 3.7.5,则安装成功。
相关问题
centos7安装python3
1. 安装依赖
```
yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel
```
2. 下载Python3源码
```
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
```
3. 解压源码
```
tar -zxvf Python-3.7.5.tgz
```
4. 进入目录
```
cd Python-3.7.5
```
5. 编译安装
```
./configure --prefix=/usr/local/python3
make && make install
```
6. 配置环境变量
```
vim /etc/profile
```
在文件末尾添加下面内容:
```
export PATH=$PATH:/usr/local/python3/bin
```
7. 使配置生效
```
source /etc/profile
```
8. 验证Python3是否安装成功
```
python3 -V
```
如果输出Python3的版本号,则安装成功。
阅读全文