Skip to content

Instantly share code, notes, and snippets.

@ttimasdf
Forked from tevino/fix_virtualenv
Last active September 4, 2019 15:18
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ttimasdf/34bc85ac008f68b2ee098850cab2979c to your computer and use it in GitHub Desktop.
Save ttimasdf/34bc85ac008f68b2ee098850cab2979c to your computer and use it in GitHub Desktop.
Fix python virtualenv after python update, forked version for choice of python executable
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
echo "Ensure the root of current virtualenv:"
echo " $ENV_PATH"
read -p "‼️ Say no if you are not sure (y/N) " -n 1 -r
echo
PYEXC_DEF="$(sed -n '1s/^#!//p' $SYSTEM_VIRTUALENV)"
read -p "🐍 Choose which python to use? [$PYEXC_DEF] " PYEXC
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "♻️ Removing old symbolic links......"
find "$ENV_PATH" -type l -delete -print
echo "💫 Creating new symbolic links......"
$SYSTEM_VIRTUALENV "$ENV_PATH" -p ${PYEXC:-$PYEXC_DEF}
echo "🎉 Done!"
fi
@trenpixster
Copy link

Thanks for this, saved me a ton of work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment