Skip to content

Commit 0ea7893

Browse files
committed
fixup! Find the highest Python version with installed virtualenvwrapper
1 parent b71ddca commit 0ea7893

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

virtualenvwrapper.sh

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,23 @@ if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ]
5050
then
5151
for NAME in python3 python2 python
5252
do
53-
PYTHON="$(command \which $NAME 2>&1)"
54-
if ! [ -z $PYTHON ]
53+
python_executable="$(which $NAME 2>/dev/null)"
54+
if ! [ -z "$python_executable" ]
5555
then
56-
if $PYTHON -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1
56+
if $python_executable -m 'virtualenvwrapper.hook_loader' --help >/dev/null 2>&1
5757
then
58-
VIRTUALENVWRAPPER_PYTHON=$PYTHON
58+
VIRTUALENVWRAPPER_PYTHON=$python_executable
5959
break
6060
fi
6161
fi
6262
done
63+
if [ "${VIRTUALENVWRAPPER_PYTHON:-}" = "" ]
64+
then
65+
echo -e "ERROR: Python with virtualenvwrapper module not found!
66+
Either, install virtualenvwrapper module for standard python2
67+
or python3 or set VIRTUALENVWRAPPER_PYTHON variable manually." 1>&2
68+
return 1
69+
fi
6370
fi
6471

6572
# Set the name of the virtualenv app to use.

0 commit comments

Comments
 (0)