Commit c83c2a5c authored by feichtinger's avatar feichtinger
Browse files

Tool to install jupyter kernel wrapper for a conda env

parent 3932a85f
...@@ -75,3 +75,35 @@ This works if the python package has a correct build ...@@ -75,3 +75,35 @@ This works if the python package has a correct build
cd /opt/psi/Programming/anaconda/2019.07/xxxx/mypackage cd /opt/psi/Programming/anaconda/2019.07/xxxx/mypackage
pip install . pip install .
``` ```
## Building for use with jupyter
Jupyter can discover conda environments if the environment contains the **nb_conda_kernels** package.
Regrettably the environment activation by this package does not run through the full process as compared to the command line functions. The activation scripts that can be placed in an environment do not get executed (q.v. my bug report
In order to fix this, we must use a workaround which involves modifying the kernel spec configuration file of the environment to wrap the call to the python kernel like in this example for `.../envs/mpi-test/share/jupyter/kernels/python3/kernel.json`:
"argv": [
"display_name": "Python 3",
"language": "python"
In order to modify an environment easily I wrote a tool found in the `admintools` of this buildblock which you can use as follows:
files/admintools/ -v /opt/psi/Programming/anaconda/2019.07/conda/envs/hep_root
#!/bin/bash #!/bin/bash
# This wrapper is needed to correctly have jupyter activate conda evnironments
# including the running of the $ENV/etc/conda/activate.d hooks
# q.v.
# This script must be called from the config located in an environment
# $ENV/share/jupyter/kernels/python3/kernel.jsonshare/jupyter/kernels/python3/kernel.json
# 2019 - Derek Feichtinger
dbgecho() { dbgecho() {
DBGLOG=/tmp/kernelwrapper-${USER}.log DBGLOG=/tmp/kernelwrapper-${USER}.log
if [[ $DEBUG_JUPYTER_WRAPPER == 1 ]]; then if [[ $DEBUG_JUPYTER_WRAPPER == 1 ]]; then
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment