diff --git a/bin/pyenv-virtualenv-prefix b/bin/pyenv-virtualenv-prefix
index aa71777..bbe5871 100755
--- a/bin/pyenv-virtualenv-prefix
+++ b/bin/pyenv-virtualenv-prefix
@@ -6,7 +6,21 @@
 
 set -e
 [ -n "$PYENV_DEBUG" ] && set -x
-. "${BASH_SOURCE%/*}"/../libexec/pyenv-virtualenv-realpath
+if [ -L "${BASH_SOURCE}" ]; then
+    READLINK=$(type -p greadlink readlink | head -1)
+    if [ -z "$READLINK" ]; then
+        echo "pyenv: cannot find readlink - are you missing GNU coreutils?" >&2
+        exit 1
+    fi
+    resolve_link() {
+        $READLINK -f "$1"
+    }
+    script_path=$(resolve_link ${BASH_SOURCE})
+else
+    script_path=${BASH_SOURCE}
+fi
+
+. ${script_path%/*}/../libexec/pyenv-virtualenv-realpath
 
 if [ -z "$PYENV_ROOT" ]; then
   PYENV_ROOT="${HOME}/.pyenv"
diff --git a/bin/pyenv-virtualenvs b/bin/pyenv-virtualenvs
index 173278b..b441e78 100755
--- a/bin/pyenv-virtualenvs
+++ b/bin/pyenv-virtualenvs
@@ -7,7 +7,21 @@
 
 set -e
 [ -n "$PYENV_DEBUG" ] && set -x
-. "${BASH_SOURCE%/*}"/../libexec/pyenv-virtualenv-realpath
+if [ -L "${BASH_SOURCE}" ]; then
+    READLINK=$(type -p greadlink readlink | head -1)
+    if [ -z "$READLINK" ]; then
+        echo "pyenv: cannot find readlink - are you missing GNU coreutils?" >&2
+        exit 1
+    fi
+    resolve_link() {
+        $READLINK -f "$1"
+    }
+    script_path=$(resolve_link ${BASH_SOURCE})
+else
+    script_path=${BASH_SOURCE}
+fi
+
+. ${script_path%/*}/../libexec/pyenv-virtualenv-realpath
 
 if [ -z "$PYENV_ROOT" ]; then
   PYENV_ROOT="${HOME}/.pyenv"
