Created
November 9, 2019 20:09
-
-
Save nathairtras/3282617b347051d568ffe0f1f17b5609 to your computer and use it in GitHub Desktop.
Script to fix all virtualenvwrapper virtual environments after Brew python upgrade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Relies on having fixvirtualenv : https://gist.github.com/nathairtras/7b2df168d9a919b4e644b1d7da0aa05d | |
# Ensure virtualenv script exists | |
if [ -z $VIRTUALENVWRAPPER_SCRIPT ] | |
then | |
echo "VirtualEnvWrapper Script Environment Variable Not Found. Please run `pip3 install virtualenvwrapper` to continue." | |
exit 1 | |
fi | |
# Ensure WORKON_HOME set | |
if [ -z $WORKON_HOME ] | |
then | |
echo "$WORKON_HOME is not set. Please ensure this is set in your environment before continuing to ensure correct execution." | |
exit 1 | |
fi | |
source $VIRTUALENVWRAPPER_SCRIPT | |
for venv in `workon` | |
do | |
workon $venv | |
python -c "" > /dev/null 2>&1 | |
BADENV=$? | |
deactivate | |
if [ $BADENV -ne 0 ] | |
then | |
fixvirtualenv $venv | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment