Skip to content

Instantly share code, notes, and snippets.

@query
Created January 23, 2014 19:15
Show Gist options
  • Save query/8584951 to your computer and use it in GitHub Desktop.
Save query/8584951 to your computer and use it in GitHub Desktop.
Fix Python virtualenvs broken by a change of Python location. Intended to be used with Homebrew, whose Python installation path contains the version number and so changes on upgrades.
#!/bin/sh
# Find and delete broken symbolic links, which cause virtualenv to balk.
# "-L" resolves symbolic links to their destination if possible, meaning
# that if the filename is still a link ("-type l"), it's a broken one.
# Since "-L" doesn't work with "-delete", this calls "rm" instead.
find -L $1 -type l -exec rm -- {} +
# Just run virtualenv again to handle the rest.
virtualenv $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment