diff --git a/demos/python/start_env.sh b/demos/python/start_env.sh index 498add5..95a0903 100755 --- a/demos/python/start_env.sh +++ b/demos/python/start_env.sh @@ -26,7 +26,9 @@ folder=jpype_env source $folder/bin/activate if [ $? -ne 0 ]; then echo "Virtual environment unable to be activated" >&2 - return 3 # Need return instead of exit since we're running via source + # Try return first in case this script was sourced. + return 3 2>/dev/null + exit 3 else echo "Python environment from $folder started and activated." fi diff --git a/demos/python/start_jupyter_env.sh b/demos/python/start_jupyter_env.sh index f902a9d..c30a279 100755 --- a/demos/python/start_jupyter_env.sh +++ b/demos/python/start_jupyter_env.sh @@ -20,9 +20,21 @@ # Start the python environment (stored in folder $folder) with jpype1, numpy and others installed # and then launch jupyter -source start_env.sh +# Name of folder to use and python commands +folder=jpype_env -echo "Started virtual environment, now starting jupyter ..." +# enter the environment +source $folder/bin/activate + +if [[ "$VIRTUAL_ENV" != "" ]] +then + echo "Started virtual environment, now starting jupyter ..." +else + echo "Virtual environment not started, exiting" + # Try return first in case this script was sourced. + return 1 2>/dev/null + exit 1 +fi cd ../.. jupyter notebook