-
Notifications
You must be signed in to change notification settings - Fork 0
/
createJupyter
executable file
·59 lines (47 loc) · 1.56 KB
/
createJupyter
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
#!/bin/bash
exec > >(tee /tmp/createJupyter.log) 2>&1
python_version="${1:-3.10.6}"
export PS4='+ (\t) ${LINENO}: '
#set -x
export PYENV_ROOT=$HOME/.pyenv
export SHELL=/usr/local/bin/bash
PATH="$PATH:/usr/local/bin"
# WhatToInstall
# nbextensions for use with "jupyter notebook"
# all_jupyter
WhatToInstall=all_jupyter
Install_nbextensions() {
# by default, since the notebook version is >= 6.0.0, all the extensions
# will be disabled, but you can uncheck, and see if one works.
#
# the latest notebook version (6.5.x) broke the nbextensions tab from appearing.
pip install notebook==6.4.12
pip install jupyter_contrib_nbextensions
# install extensions in virtual environment (not enabled yet)
jupyter contrib nbextension install --prefix $(pyenv prefix jupyter)
# let user decide which extension to enable in nbextensions tab
jupyter nbextensions_configurator enable
}
Install_all_jupyter() {
pip install jupyterlab
pip install voila
# install older notebook that may work with extensions tab
Install_nbextensions
# pip install notebook
}
if command -v pyenv > /dev/null 2>&1; then
PATH="$PATH:$PYENV_ROOT/shims:$HOME/bin"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
pyenv install --skip-existing $python_version
pyenv virtualenv $python_version jupyter
VENV=$(pyenv local)
pyenv local jupyter
pip install -U pip
pip install ipykernel
eval "Install_${WhatToInstall}" || exit 1
pyenv local $VENV
else
echo "pyenv doesn't appear to exist in $PATH"
exit 1
fi