Skip to content

Instantly share code, notes, and snippets.

@phi-line
Last active August 22, 2018 23:57
Show Gist options
  • Save phi-line/36cc277877ea1b6cc84798cb840aa86b to your computer and use it in GitHub Desktop.
Save phi-line/36cc277877ea1b6cc84798cb840aa86b to your computer and use it in GitHub Desktop.
# virtualenv --python=/usr/local/bin/python2.7 <path/to/new/virtualenv/
# virtualenv --python=/usr/local/bin/python3.7 <path/to/new/virtualenv/
set_python_version() {
while true; do
echo -n "Please choose Python2 or Python3 (2/3): "
read python_version
if [ "$python_version" = "2" ]; then
echo "Activating: Python 2.7 >> ~/env/bin/activate"
export PYTHONPATH=/Users/username/env/lib/python2.7/site-packages:/Users/username/git
source ~/env/bin/activate
break
elif [ "$python_version" = "3" ]; then
echo "Activating: Python 3.7 >> ~/env3/bin/activate"
export PYTHONPATH=/Users/username/env3/lib/python3.7/site-packages:/Users/username/git
source ~/env3/bin/activate
break
fi
done
}
set_python_version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment