-
-
Save markcheno/45981b31ffc1bba43832f814c0164f6b to your computer and use it in GitHub Desktop.
Register a jupyter kernel for the current pyenv.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ "$PYENV_VERSION" -ne "" ] | |
then | |
name=`pyenv version-name` | |
python=`pyenv which python` | |
else | |
name=`basename "$VIRTUAL_ENV"` | |
python="$VIRTUALENV/bin/python" | |
fi | |
jupyterdir=$(jupyter --data-dir) | |
kerneldir="${jupyterdir}/kernels/${name}" | |
echo "Installing jupyter kernel file $name for $python to $kerneldir ..." | |
pip install ipykernel | |
mkdir -p "$kerneldir" | |
cat > "$kerneldir"/kernel.json <<EOF | |
{ | |
"argv": [ "$python", "-m", "ipykernel", "-f", "{connection_file}" ], | |
"display_name": "$name", | |
"language": "python" | |
} | |
EOF | |
cat "$kerneldir"/kernel.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment