Skip to content

Instantly share code, notes, and snippets.

@AdamGagorik
Created June 22, 2023 13:18
Show Gist options
  • Save AdamGagorik/ac5f8883af32159bd7fb104a4e82eb8b to your computer and use it in GitHub Desktop.
Save AdamGagorik/ac5f8883af32159bd7fb104a4e82eb8b to your computer and use it in GitHub Desktop.
if [[ ! -d ./.venv ]]; then
echo "no virtual environment in current directory"
exit 1
fi
. .venv/bin/activate
PYVER=`python --version | cut -d " " -f2`
DNAME="[${PYVER}]: ${PWD}"
KNAME=${PWD##*/}
echo "DISPLAY NAME: ${DNAME}"
echo "KERNEL NAME: ${KNAME}"
echo
jupyter kernelspec list
echo
jupyter kernelspec uninstall ${KNAME} || true
echo
read -p "Create kernel: ${KNAME}? [y/N]: " -n 2 -r choice
case "$choice" in
y|Y)
echo
python -m ipykernel install --user --display-name "${DNAME}" --name "${KNAME}"
echo
jupyter kernelspec list
;;
*) echo "skipping..."
;;
esac
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment