-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathInstallPython.sh
executable file
·72 lines (67 loc) · 1.94 KB
/
InstallPython.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
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
#!/bin/bash
##@brief Create a Python environment
##@author Jianping Meng
##@contributors
##@details
function usage {
echo "This script will download, compile and install the OPS library to a specified directory!"
echo "./$(basename $0) -h -> Showing usage"
echo "./$(basename $0) -d -> Specifying the directory (absolute path) for installing Python"
echo "./$(basename $0) -p -> Use Python2"
}
optstring="hd:p"
Dir="$HOME/Python"
PackageName="Miniconda3-py37_22.11.1-1-Linux-x86_64.sh" # 3.7
while getopts ${optstring} options; do
case ${options} in
h)
usage
exit 0
;;
d)
Dir=${OPTARG}
;;
p)
PackageName="Miniconda2-py27_4.8.3-Linux-x86_64.sh"
;;
:)
echo "$0: Must supply an argument to -$OPTARG." >&2
exit 1
;;
?)
echo "Invalid option: -${OPTARG}."
exit 2
;;
esac
done
if [ -d "$Dir" ]
then
echo "The specified directory is exising, please delete it first or change to another one!"
exit 1
fi
wget -c https://repo.anaconda.com/miniconda/${PackageName}
chmod a+x ./${PackageName}
./${PackageName} -b -p ${Dir}
source "$Dir/bin/activate" "$Dir"
pip install sympy==1.1
pip install numpy matplotlib h5py scipy jinja2 commentjson
# if [ ! -d "$HOME/bin" ]
# then
# mkdir -p $HOME/bin
# fi
rm ${PackageName}
pip cache purge
#cd $HOME/bin
# echo "#!/bin/bash" > Python2
# echo "echo \"The default shell for Python2 is bash. Enter the shell name to change\" " >> Python2
# echo "if [ \$# -eq 0 ]" >> Python2
# echo "then" >> Python2
# echo " shell=\"bash\" " >> Python2
# echo "else" >> Python2
# echo " shell=\$1" >> Python2
# echo "fi" >> Python2
# echo "source $dir/bin/activate" >> Python2
# echo "\$shell" >> Python2
# chmod a+x Python2
# echo "$HOME/bin/Python2 can be called to activate the Python2 environment!"
# echo "Consider to add $HOME/bin to path"