-
Notifications
You must be signed in to change notification settings - Fork 3
/
Python3.sh
42 lines (35 loc) · 1000 Bytes
/
Python3.sh
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
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
# 文件名: Python3.sh
# 描述: 用于 CentOS 7 系统编译安装 Python3
# 版本: 3.6.2
# 创建时间: 2016年11月02日
# 修订: 2017年9月28日
# 作者: Selphia (sp), admin@factory.moe
# 变量
python="3.7.3"
### 检测是否安装GCC
gcc --version
if [ $? != 0 ]
then
echo 'Before you proceed, make sure that your system has a C compiler'
exit 0
fi
# 解决依赖
yum install gcc zlib zlib-devel openssl openssl-devel sqlite-devel bzip2-devel expat-devel gdbm-devel readline-devel -y
# 下载、解压、编译、安装Python
wget "https://www.python.org/ftp/python/$python/Python-$python.tar.xz"
tar -xvf "Python-$python.tar.xz"
cd "./Python-$python"
./configure --prefix=/usr/local/python3 --enable-shared
make all
make install
# 设置链接
ln -sf /usr/local/python3/bin/* /usr/bin
echo "/usr/local/python3/lib" >> /etc/ld.so.conf
ldconfig
# 更新pip3、安装wheel
pip3 install --upgrade pip
pip3 install setuptools
pip3 install wheel
# 结束
python3 -V