-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-python2.sh
More file actions
executable file
·90 lines (68 loc) · 2.33 KB
/
install-python2.sh
File metadata and controls
executable file
·90 lines (68 loc) · 2.33 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# Compile and nstall Python 2.7.x from source, and install pip.
VERSION="2.7.18"
VER=$(echo ${VERSION} | awk 'BEGIN{FS="."} {print $1"."$2}')
# --------------------------------------------------
# Update the package and install the requirements.
# --------------------------------------------------
sudo apt-get update && sudo apt-get install -y \
build-essential \
tk-dev \
zlib1g-dev \
libncurses5-dev \
libgdbm-dev \
libnss3-dev \
libssl-dev \
libsqlite3-dev \
libreadline-dev \
libffi-dev \
libbz2-dev
# --------------------------------------------------
# Create the temporary directory.
# --------------------------------------------------
if [ ! -d ${HOME}/temp ]; then
mkdir ${HOME}/temp
fi
# --------------------------------------------------
# Download the source code.
# --------------------------------------------------
cd ${HOME}/temp
wget https://www.python.org/ftp/python/${VERSION}/Python-${VERSION}.tgz
tar -xvf Python-${VERSION}.tgz
# --------------------------------------------------
# Compile the source code and install.
# --------------------------------------------------
cd Python-${VERSION}
./configure --enable-optimizations
sudo make
sudo make altinstall
# --------------------------------------------------
# Check whether Python 2.7.x install succeed.
# --------------------------------------------------
if [ ! -x /usr/local/bin/python${VER} ]; then
echo "ERROR! Python ${VERSION} is not install correctly."
cd ${HOME}
sudo rm -rf ${HOME}/temp/Python-${VERSION}
rm ${HOME}/temp/Python-${VERSION}.tgz
exit 1
fi
# --------------------------------------------------
# Download pip
# --------------------------------------------------
cd ${HOME}/temp
wget https://bootstrap.pypa.io/pip/${VER}/get-pip.py
/usr/local/bin/python${VER} get-pip.py
# --------------------------------------------------
# Check whether Python 2.7.x install succeed.
# --------------------------------------------------
if [ ! -x ${HOME}/.local/bin/pip${VER} ]; then
echo "ERROR! PIP ${VER} is not install correctly."
exit 1
fi
# --------------------------------------------------
# Make clean.
# --------------------------------------------------
sudo rm -rf ${HOME}/temp/Python-${VERSION}
rm ${HOME}/temp/Python-${VERSION}.tgz
rm ${HOME}/temp/get-pip.py
# END