Skip to content

Instantly share code, notes, and snippets.

@oogali
Created October 13, 2017 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oogali/a2d51ea8acd2fa193a9c46986ba7f959 to your computer and use it in GitHub Desktop.
Save oogali/a2d51ea8acd2fa193a9c46986ba7f959 to your computer and use it in GitHub Desktop.
Snippet to insert into .bash_profile for reliable local Jupyter execution (assumes you have Jupyter installed)
function frameworkpython {
if [[ ! -z "$VIRTUAL_ENV" ]]; then
PYTHONHOME=$VIRTUAL_ENV /usr/bin/python "$@"
else
/usr/bin/python "$@"
fi
}
function jupyter {
jcmd=$1
shift
if [[ ! -z "$VIRTUAL_ENV" ]]; then
jupyter_prefix="${VIRTUAL_ENV}/bin/jupyter"
else
jupyter_prefix="$(which jupyter)"
fi
if [[ -z "${jupyter_prefix}" ]]; then
echo "Could not find Jupyter in your path"
exit 1
fi
frameworkpython "${jupyter_prefix}-${jcmd}" "$@"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment