Skip to content

Instantly share code, notes, and snippets.

@markeissler
Forked from tevino/fix_virtualenv
Last active July 10, 2017 20:52
Show Gist options
  • Save markeissler/fc3d65657f0d607531450f84bfc22536 to your computer and use it in GitHub Desktop.
Save markeissler/fc3d65657f0d607531450f84bfc22536 to your computer and use it in GitHub Desktop.
Fix python virtualenv after python update
#!/usr/bin/env bash
ENV_PATH="$(dirname "$(dirname "$(which pip)")")"
SYSTEM_VIRTUALENV="$(which -a virtualenv|tail -1)"
GNUFIND_PATH="$(which -a gfind|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
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo "♻️ Removing old symbolic links......"
if [[ -x "$GNUFIND_PATH" ]]; then
"$GNUFIND_PATH" "$ENV_PATH" -type l -xtype l -print -delete
else
find "$ENV_PATH" -type l -delete -print
fi
echo "💫 Creating new symbolic links......"
$SYSTEM_VIRTUALENV "$ENV_PATH"
echo "🎉 Done!"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment