-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.sh
More file actions
executable file
·72 lines (64 loc) · 1.89 KB
/
python.sh
File metadata and controls
executable file
·72 lines (64 loc) · 1.89 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
#!/usr/bin/env bash
### MAC_NOTES_FOLDER
MAC_NOTES_FOLDER="${HOME}/Workspace/mac-os-x-notes"
if [ ! -r "${MAC_NOTES_FOLDER}" ]; then
echo "Error reading ${MAC_NOTES_FOLDER}" 1>&2
exit 1
fi
### Check that conda is installed
if [[ ! $(which conda) ]]; then
echo "Cannot find command 'conda'" 1>&2
echo "Please install anaconda or miniconda" 1>&2
exit 1
fi
### .bashrc
chmod +x "${MAC_NOTES_FOLDER}/bashrc.sh"
"${MAC_NOTES_FOLDER}/bashrc.sh"
### The Python section
if [[ ! $(grep '# python' "${HOME}/.bashrc") ]]; then
echo '# python' >> "${HOME}/.bashrc"
fi
# Check if a conda env already exists
function check_conda_env() {
if [[ $(conda env list | grep -E ".+/envs/${1}$") ]]; then
# As bash functions cannot return values, use command substitution
echo "true"
return 0
fi
return 0
}
### ipython (or jupyter)
if [[ ! $(check_conda_env ipython) ]]; then
cd
conda create --yes --name ipython python=3
source activate ipython
conda install --yes ipython-notebook
conda install --yes requests
conda install --yes sqlite
source deactivate
echo 'alias env-ipython="source activate ipython"' >> "${HOME}/.bashrc"
fi
### scikit-learn
if [[ ! $(check_conda_env sklearn) ]]; then
cd
conda create -y -n sklearn --clone ipython
source activate sklearn
conda install -y numpy
conda install -y scipy
conda install -y matplotlib
conda install -y pandas
conda install -y sympy
conda install -y scikit-learn
conda install -y seaborn
source deactivate
echo 'alias env-sklearn="source activate sklearn"' >> "${HOME}/.bashrc"
fi
### scikit-image
if [[ ! $(check_conda_env skimage) ]]; then
cd
conda create -y -n skimage --clone sklearn
source activate skimage
conda install -y scikit-image
source deactivate
echo 'alias env-skimage="source activate skimage"' >> "${HOME}/.bashrc"
fi