clean-jupyterlab.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #!/bin/bash
  2. #
  3. # Copyright 2018-2022 Elyra Authors
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. ################################################################################
  18. # INSTRUCTIONS:
  19. # This script is intended to help clean your JupyterLab/Elyra environment. It can be very useful when switching back and forth between different JupyterLab versions during the development of Elyra.
  20. # It is recommended to use a virtual environment (eg. conda env).
  21. # It reinstalls JupyterLab after an environment cleanup.
  22. #
  23. # Make sure you have a conda environment setup (https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)
  24. # Export the variable ANACONDA_HOME with your conda installation path to the environment:
  25. # export ANACONDA_HOME='/Users/my_username/my_anaconda_dir/'
  26. #
  27. # WARNING: The following resources will be deleted:
  28. # ~/.jupyter
  29. # $ANACONDA_HOME/etc/jupyter
  30. # $ANACONDA_HOME/share/jupyter
  31. # $ANACONDA_HOME/envs/$CONDA_DEFAULT_ENV/etc/jupyter
  32. # $ANACONDA_HOME/envs/$CONDA_DEFAULT_ENV/share/jupyter
  33. #
  34. # To install a specific JupyterLab version, run the script adding the version argument as below:
  35. # etc/scripts/clean-jupyterlab.sh --version 2.2.9
  36. # When no argument is passed to the command, it will install the latest JupyterLab version.
  37. ################################################################################
  38. echo "This script removes your JupyterLab installation"
  39. echo "Any packages or data stored in your JupyterLab environment will be removed"
  40. echo " "
  41. read -p "Press ENTER to continue or CTRL+C to abort"
  42. ANACONDA_HOME=${ANACONDA_HOME:='~/anaconda'}
  43. LAB_VERSION=""
  44. if [ "$1" = "--version" ]
  45. then
  46. LAB_VERSION="==$2"
  47. fi
  48. echo "Anaconda..........: $ANACONDA_HOME"
  49. echo "Anaconda env......: $CONDA_DEFAULT_ENV"
  50. echo " "
  51. set -e
  52. echo "Uninstalling old packages and kernels"
  53. conda uninstall -y xeus-python -c conda-forge || true;
  54. conda uninstall -y r r-essentials r-irkernel || true;
  55. conda uninstall -y r-languageserver -c conda-forge || true;
  56. pip uninstall -y elyra || true;
  57. pip uninstall -y jupyterlab-git || true;
  58. pip uninstall -y jupyterlab-server || true;
  59. pip uninstall -y jupyterlab || true;
  60. pip uninstall -y nbdime || true;
  61. echo " "
  62. echo "Cleaning jupyter and jupyterlab workspace"
  63. rm -rf ~/.jupyter
  64. rm -rf $ANACONDA_HOME/etc/jupyter
  65. rm -rf $ANACONDA_HOME/share/jupyter
  66. rm -rf $ANACONDA_HOME/envs/$CONDA_DEFAULT_ENV/etc/jupyter
  67. rm -rf $ANACONDA_HOME/envs/$CONDA_DEFAULT_ENV/share/jupyter/lab
  68. rm -rf $ANACONDA_HOME/envs/$CONDA_DEFAULT_ENV/share/jupyter/labextensions
  69. rm -rf $ANACONDA_HOME/envs/$CONDA_DEFAULT_ENV/share/jupyter/nbconvert
  70. echo " "
  71. echo "Installing/Updating JupyterLab"
  72. pip install --upgrade pip wheel
  73. pip install --upgrade tornado
  74. if [ "$LAB_VERSION" != "==dev" ]
  75. then
  76. pip install --upgrade "jupyterlab$LAB_VERSION"
  77. fi
  78. echo " "
  79. echo "Installing Xeus kernel"
  80. XPYTHON_VERSION="$(python --version 2>&1)"
  81. if [[ "$XPYTHON_VERSION" == *"Python 3.6"* ]]
  82. then
  83. conda install -y xeus-python">=0.8.0,<0.9.0" -c conda-forge
  84. else
  85. conda install -y xeus-python">=0.9.3" -c conda-forge
  86. fi
  87. echo " "
  88. echo "Installing R kernel and language server"
  89. conda install -y r r-essentials r-irkernel
  90. conda install -y -c conda-forge r-languageserver
  91. echo " "
  92. if [ "$LAB_VERSION" != "==dev" ]
  93. then
  94. jupyter --version
  95. echo " "
  96. jupyter kernelspec list
  97. echo " "
  98. jupyter server extension list
  99. echo " "
  100. jupyter labextension list
  101. echo " "
  102. fi