Snippets

Steven Berlan Regenerate python virtual environments

Created by Steven Berlan last modified
#!/bin/sh
. $(brew --prefix)/bin/virtualenvwrapper.sh

# Delete pip cache since we are rebuilding all the virtualenvs
rm -rf ~/Library/Caches/pip

for venv in $(ls -d */); do
    venv=${venv:0:((${#venv} - 1))}
    project=$(cat $venv/.project 2>/dev/null)
    if [ -n "$venv" ] && [ -r "$project" ]; then
        echo "== $venv ==========================================================="
        echo ""
        rm -rf "$WORKON_HOME/$venv"
        pushd "$project" >/dev/null
        mkvirtualenv "$venv"
        popd >/dev/null
    fi
done

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.