0%

Python基础--Python安装

Python基础–Python安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
yum clean all
rm -rf /etc/yum.repos.d/*
curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum -y install wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

yum install epel-release -y


# 下载Python
url: https://www.python.org/downloads/source/
选择所需的版本下载, 我这里选择的是Linux系统的Python3.8.6

cd /home
wget https://www.python.org/ftp/python/3.8.6/Python-3.8.6.tar.xz

# 安装系统依赖包
yum install -y python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
yum update -y

# 解压
tar -xvf Python-3.8.6.tar.xz

# 编译安装 指定路径 并添加ssl模块
cd Python-3.8.6
./configure --prefix=/usr/local/python3 --with-ssl
make && make install

# 添加软连接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3