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.

Revisions

  1. phi-line revised this gist Aug 22, 2018. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions python2-3_switcher
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,18 @@
    # 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/kishan/env/lib/python2.7/site-packages:/Users/kishan/Better
    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/kishan/env3/lib/python3.7/site-packages:/Users/kishan/Better
    export PYTHONPATH=/Users/username/env3/lib/python3.7/site-packages:/Users/username/git
    source ~/env3/bin/activate
    break
    fi
  2. phi-line created this gist Aug 22, 2018.
    18 changes: 18 additions & 0 deletions python2-3_switcher
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    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/kishan/env/lib/python2.7/site-packages:/Users/kishan/Better
    source ~/env/bin/activate
    break
    elif [ "$python_version" = "3" ]; then
    echo "Activating: Python 3.7 >> ~/env3/bin/activate"
    export PYTHONPATH=/Users/kishan/env3/lib/python3.7/site-packages:/Users/kishan/Better
    source ~/env3/bin/activate
    break
    fi
    done
    }
    set_python_version