Changes between Version 41 and Version 42 of Jupyter
- Timestamp:
- 05/22/18 10:36:48 (6 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Jupyter
v41 v42 76 76 77 77 ==== Setup your own specialized Jupyter-Kernel 78 The installed kernels might not suite your needs and you want to switch to a different software stage or want to load additional software modules. \\In that case you need to set up your own specialized Jupyter kernel.\\ This can be done in a few steps: 79 80 Create a new Python virtual environment (e.g. in $HOME/**venv_mykernel**/) \\ 81 with a basic Jupyter kernel (e.g. in ${HOME}/.local/share/jupyter/kernels/**mykernel**) 82 83 1. LOAD the modules you need and ensure Python3 is included! 78 The installed kernels might not suite your needs and you want to switch to a different software stage or want to load additional software modules. \\In that case you need to set up your own specialized Jupyter kernel.\\ This can be done in the terminal in a few steps on the supercomputer: 79 * LOAD the modules you need 80 * start with ''module --force purge'' to remove any module which is already loaded 81 * ensure this includes a recent Python 3.x (even if you are not planing to use Python) 82 * example: 84 83 {{{ #!ShellExample 85 84 module --force purge … … 89 88 }}} 90 89 91 2. CREATE Python virtual environment in $HOME/venv_mykernel 90 * CREATE a new Python virtual environment on the supercomputer 91 * e.g. in ''$HOME/venv_mykernel/'' 92 * more: https://docs.python.org/3/library/venv.html 93 * example: 92 94 {{{ #!ShellExample 93 95 cd $HOME 94 96 python3 -m venv venv_mykernel 95 97 }}} 96 more: https://docs.python.org/3/library/venv.html 97 98 3. ACTIVATE new Python virtual environment 98 99 * ACTIVATE the new Python virtual environment (VENV) in your terminal 100 * the loaded modules modify $PYTHONPATH (''python -m site'') 101 * ensure(!!!) the first entry is the ''site-package'' directory of your VENV 102 * ''export PYTHONPATH=<DIR-OF-VENV>/lib/python3.6/site-packages:${PYTHONPATH}'' 103 * example: 99 104 {{{ #!ShellExample 100 105 source ${HOME}/venv_mykernel/bin/activate 101 export PYTHONPATH=${HOME}/venv_mykernel/lib/python3.6/site-packages:${PYTHONPATH} 102 }}} 103 104 4. CREATE your personal Jupyter kernel 106 (venv)$ export PYTHONPATH=${HOME}/venv_mykernel/lib/python3.6/site-packages:${PYTHONPATH} 107 }}} 108 109 * PIMP your VENV 110 * install ipykernel with ''pip'' 111 * install any other python software you need with ''pip'' 112 * example: 105 113 {{{ #!ShellExample 106 114 (venv) $ pip install ipykernel 115 (venv) $ <install whatever else you need in your Python virtual environment using pip> 116 }}} 117 118 * INSTALL your personal Jupyter kernel 119 * location of the new Jupyter kernel: ''${HOME}/.local/share/jupyter/kernels/mykernel/'' 120 * more: http://ipython.readthedocs.io/en/stable/install/kernel_install.html 121 * example: 122 {{{ #!ShellExample 107 123 (venv) $ python3 -m ipython kernel install --user --name=mykernel 108 (venv) $ <install whatever else you need in your Python virtual environment using pip> 109 }}} 110 This installs your personal Jupyter kernel in ${HOME}/.local/share/jupyter/kernels/mykernel \\more: http://ipython.readthedocs.io/en/stable/install/kernel_install.html 124 }}} 111 125 112 126 Now, modify this basic jupyter kernel to suite your needs. 113 127 114 5. WRITE A SCRIPT (${HOME}/venv_mykernel/mykernel.sh) that does your setup followed by the IPython kernel launch: 115 a. load the same modules as in (1) 116 b. load the Python virtual environment as in (2) 128 * WRITE a script (e.g. ${HOME}/venv_mykernel/mykernel.sh) 129 * that sets up your environment 130 * load the same modules as in (1) 131 * followed by the IPython kernel launch 132 * load the Python virtual environment as in (2) 133 * example: 117 134 {{{ #!ShellExample 118 135 #!/usr/bin/env bash … … 129 146 }}} 130 147 131 6. MODIFY the ${HOME}/.local/share/jupyter/kernels/mykernel/kernel.json file to call your script: 148 * MODIFY the Jupyter kernel configuration file 149 * located in ${HOME}/.local/share/jupyter/kernels/mykernel/kernel.json file 150 * it must call your launch script: 151 * example: 132 152 {{{ #!ShellExample 133 153 "argv": [