Most likely what's happening is you don't have your PATH
variable exported to the environment. In that case, /usr/bin/env
won't have a PATH
set, and its execvp
call will end up searching a small set of default directories (which typically includes /usr/bin
, naturally).
To see this (in bash
):
$ export PATH
$ declare -p PATH # verify PATH is exported, denoted by the -x
declare -x PATH="<my usual path, omitted...>"
$ /usr/bin/env python -V # shows my own python build
Python 2.7.6
$ export -n PATH # un-export PATH
$ declare -p PATH
declare -- PATH="<my usual path, omitted...>"
$ /usr/bin/env python -V # shows the system (/usr/bin/python) version
Python 2.6.6
So, in summary, make sure to export PATH
somewhere in your shell dotfiles.