Skip to content

Instantly share code, notes, and snippets.

@chriswayg
Last active July 23, 2020 06:12
Show Gist options
  • Save chriswayg/ee97606a4dc93a4cdacff90915d5d1e5 to your computer and use it in GitHub Desktop.
Save chriswayg/ee97606a4dc93a4cdacff90915d5d1e5 to your computer and use it in GitHub Desktop.

Revisions

  1. chriswayg revised this gist Jul 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ set -o errexit
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonlister.sh)"

    # Download, install with sudo in /usr/local/ and run the script
    # f=/usr/local/bin/pythonlister && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonlister.sh && sudo chmod +x $f && pythonlister
    # f=/usr/local/bin/pythonlister; sudo mkdir -p /usr/local/bin && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonlister.sh && sudo chmod +x $f && pythonlister

    # make sure you understand the script, before you install it with sudo.

  2. chriswayg revised this gist Jul 23, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,7 @@ findPython=("2.3" "2.4" "2.5" "2.6" "2.7" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3
    #printf "\n*** Searching for Python " && echo ${findPython[@]}

    checkPaths=("/System/Library/Frameworks/Python.framework/Versions" \
    "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions" \
    "/Library/Frameworks/Python.framework/Versions" \
    "$HOME/Library/Frameworks/Python.framework/Versions" \
    "/usr/local/Cellar/python*/*/Frameworks/Python.framework/Versions" \
    @@ -42,6 +43,9 @@ for searchPath in ${checkPaths[@]}; do
    /System/Library/Frameworks/Python.framework/*)
    installedBy="macOS in System"
    ;;
    /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/*)
    installedBy="Xcode CLT in Library"
    ;;
    */Library/Frameworks/Python.framework/*)
    installedBy="Python.org in Library"
    ;;
  3. chriswayg revised this gist Jul 19, 2020. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,7 @@ for searchPath in ${checkPaths[@]}; do
    #echo "- looking for python${ver}"
    path_of_python=$searchPath/${ver}*/bin/python${ver}
    if command -v $path_of_python &> /dev/null; then
    printf "==> $path_of_python - " && $path_of_python -V || True
    printf "==> $path_of_python - " && $path_of_python -V 2>&1 | head -n 4
    fi
    done
    fi
    @@ -102,7 +102,7 @@ for searchPath in ${checkPaths[@]}; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf "${color}==> $path_of_python - ${reset}" && $path_of_python -V || True
    printf "${color}==> $path_of_python - ${reset}" && $path_of_python -V 2>&1 | head -n 4
    fi
    done
    fi
    @@ -119,23 +119,23 @@ for ver in "${findPython[@]}"; do
    #echo "- looking for $pythonver"
    if command -v $pythonver &> /dev/null; then
    printf "${color}The command '$pythonver' will run ${reset}" && which $pythonver
    printf "==> Version: " && $pythonver -V || True
    printf "==> Version: " && $pythonver -V 2>&1 | head -n 4
    fi
    done

    if command -v pip -V &> /dev/null; then
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "==> Version: " && pip -V || True
    printf "==> Version: " && pip -V 2>&1 | head -n 4
    fi

    if command -v pip3 -V &> /dev/null; then
    printf "${color}The command 'pip3' will run ${reset}" && which pip3
    printf "==> Version: " && pip3 -V || True
    printf "==> Version: " && pip3 -V 2>&1 | head -n 4
    fi

    if command -v pipenv --version &> /dev/null; then
    printf "${color}The command 'pipenv' will run ${reset}" && which pipenv
    printf "==> Version: " && pipenv --version || True
    printf "==> Version: " && pipenv --version 2>&1 | head -n 4
    fi

    printf "\n"
  4. chriswayg revised this gist Jul 19, 2020. 1 changed file with 28 additions and 16 deletions.
    44 changes: 28 additions & 16 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -94,18 +94,18 @@ for searchPath in ${checkPaths[@]}; do
    installedBy="Unknown"
    ;;
    esac
    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}\n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf "${color}==> $path_of_python - ${reset}" && $path_of_python -V || True
    fi
    done
    fi

    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}\n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf "${color}==> $path_of_python - ${reset}" && $path_of_python -V || True
    fi
    done
    fi
    done
    printf "\n============== Listing currently activated Python versions ===============\n"
    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    @@ -122,10 +122,22 @@ for ver in "${findPython[@]}"; do
    printf "==> Version: " && $pythonver -V || True
    fi
    done
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "==> Version: " && pip -V || True
    printf "${color}The command 'pip3' will run ${reset}" && which pip3
    printf "==> Version: " && pip3 -V || True

    if command -v pip -V &> /dev/null; then
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "==> Version: " && pip -V || True
    fi

    if command -v pip3 -V &> /dev/null; then
    printf "${color}The command 'pip3' will run ${reset}" && which pip3
    printf "==> Version: " && pip3 -V || True
    fi

    if command -v pipenv --version &> /dev/null; then
    printf "${color}The command 'pipenv' will run ${reset}" && which pipenv
    printf "==> Version: " && pipenv --version || True
    fi

    printf "\n"

    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "${color}==> NOTE:${reset} you are running in a virtual environment! \n\n"
  5. chriswayg revised this gist Jul 19, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -124,7 +124,7 @@ for ver in "${findPython[@]}"; do
    done
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "==> Version: " && pip -V || True
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "${color}The command 'pip3' will run ${reset}" && which pip3
    printf "==> Version: " && pip3 -V || True
    printf "\n"

  6. chriswayg revised this gist Jul 19, 2020. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -122,6 +122,10 @@ for ver in "${findPython[@]}"; do
    printf "==> Version: " && $pythonver -V || True
    fi
    done
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "==> Version: " && pip -V || True
    printf "${color}The command 'pip' will run ${reset}" && which pip
    printf "==> Version: " && pip3 -V || True
    printf "\n"

    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "${color}==> NOTE:${reset} you are running in a virtual environment! \n\n"
  7. chriswayg revised this gist Jul 19, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -94,8 +94,8 @@ for searchPath in ${checkPaths[@]}; do
    installedBy="Unknown"
    ;;
    esac
    printf "${color}*** Installed by $installedBy: ${reset}\n"
    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}\n"
    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}\n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
  8. chriswayg revised this gist Jul 19, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -94,7 +94,7 @@ for searchPath in ${checkPaths[@]}; do
    installedBy="Unknown"
    ;;
    esac
    printf "\n${color}*** Installed by $installedBy: ${reset}\n"
    printf "${color}*** Installed by $installedBy: ${reset}\n"
    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}\n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
  9. chriswayg revised this gist Jul 19, 2020. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ for searchPath in ${checkPaths[@]}; do
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n${color}*** Installed by $installedBy: ${reset}" && ls $searchPath/
    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}" && ls $searchPath/
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    @@ -94,8 +94,8 @@ for searchPath in ${checkPaths[@]}; do
    installedBy="Unknown"
    ;;
    esac
    printf "\n${color}==> Installed by $installedBy: ${reset}\n"
    [[ -d $searchPath/ ]] && printf "\n${color}*** Installed by $installedBy: ${reset}\n"
    printf "\n${color}*** Installed by $installedBy: ${reset}\n"
    [[ -d $searchPath/ ]] && printf "${color}*** Installed by $installedBy: ${reset}\n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    @@ -111,17 +111,17 @@ printf "\n============== Listing currently activated Python versions ========
    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}

    printf "** In PATH: $PATH\n"
    printf "${color}*** In PATH:${reset} $PATH\n"

    for ver in "${findPython[@]}"; do
    [[ $ver == "Python" ]] && ver=""
    pythonver="python${ver}"
    #echo "- looking for $pythonver"
    if command -v $pythonver &> /dev/null; then
    printf "\n${color}* The command '$pythonver' will run ${reset}" && which $pythonver
    printf "${color}==> Version: ${reset}" && $pythonver -V || True
    printf "${color}The command '$pythonver' will run ${reset}" && which $pythonver
    printf "==> Version: " && $pythonver -V || True
    fi
    done
    printf "\n"

    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "NOTE: you are running in a virtual environment! \n\n"
    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "${color}==> NOTE:${reset} you are running in a virtual environment! \n\n"
  10. chriswayg revised this gist Jul 19, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -13,7 +13,7 @@ set -o errexit

    color="$(tput bold; tput setaf 5)"
    reset="$(tput sgr0)"
    clear
    #clear
    printf "============== LIST INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
    #printf "The script will display 'python --version' for the Python executables\n"
    #printf "found in the file-system and in the PATH\n"
    @@ -63,7 +63,7 @@ for searchPath in ${checkPaths[@]}; do
    #echo "- looking for python${ver}"
    path_of_python=$searchPath/${ver}*/bin/python${ver}
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    printf "==> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
  11. chriswayg revised this gist Jul 16, 2020. 1 changed file with 0 additions and 0 deletions.
    Empty file removed 1
    Empty file.
  12. chriswayg revised this gist Jul 15, 2020. 2 changed files with 10 additions and 11 deletions.
    Empty file added 1
    Empty file.
    21 changes: 10 additions & 11 deletions pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,8 @@ set -o errexit

    # make sure you understand the script, before you install it with sudo.

    color="$(tput bold; tput setaf 5)"
    reset="$(tput sgr0)"
    clear
    printf "============== LIST INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
    #printf "The script will display 'python --version' for the Python executables\n"
    @@ -54,7 +56,7 @@ for searchPath in ${checkPaths[@]}; do
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: " && ls $searchPath/
    [[ -d $searchPath/ ]] && printf "\n${color}*** Installed by $installedBy: ${reset}" && ls $searchPath/
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    @@ -92,22 +94,20 @@ for searchPath in ${checkPaths[@]}; do
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: \n"
    printf "\n${color}==> Installed by $installedBy: ${reset}\n"
    [[ -d $searchPath/ ]] && printf "\n${color}*** Installed by $installedBy: ${reset}\n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    printf "${color}==> $path_of_python - ${reset}" && $path_of_python -V || True
    fi
    done
    fi
    done
    printf "\n"
    read -rsn1 -p"======== Press any key to show currently activated Python versions ========";echo

    printf "\n============== Listing currently activated Python versions ===============\n"
    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}

    @@ -118,11 +118,10 @@ for ver in "${findPython[@]}"; do
    pythonver="python${ver}"
    #echo "- looking for $pythonver"
    if command -v $pythonver &> /dev/null; then
    printf "\n* The command '$pythonver' will run " && which $pythonver
    printf ">>> Version: " && $pythonver -V || True

    printf "\n${color}* The command '$pythonver' will run ${reset}" && which $pythonver
    printf "${color}==> Version: ${reset}" && $pythonver -V || True
    fi
    done
    printf "\n"

    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "\nNOTE: you are running in a virtual environment! \n\n"
    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "NOTE: you are running in a virtual environment! \n\n"
  13. chriswayg revised this gist Jul 15, 2020. No changes.
  14. chriswayg renamed this gist Jul 15, 2020. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions pythonfinder.sh → pythonlister.sh
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    #!/bin/bash
    set -o errexit
    # pythonfinder version 0.3
    # pythonlister version 0.3
    # License: MIT - (c) 2020 ChrisWayg

    # Run the script directly
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh)"
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonlister.sh)"

    # Download, install with sudo in /usr/local/ and run the script
    # f=/usr/local/bin/pythonfinder && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder
    # f=/usr/local/bin/pythonlister && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonlister.sh && sudo chmod +x $f && pythonlister

    # make sure you understand the script, before you install it with sudo.

    clear
    printf "============== FIND INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
    printf "============== LIST INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
    #printf "The script will display 'python --version' for the Python executables\n"
    #printf "found in the file-system and in the PATH\n"

  15. chriswayg revised this gist Jul 11, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -106,7 +106,7 @@ for searchPath in ${checkPaths[@]}; do
    fi
    done
    printf "\n"
    read -rsn1 -p"======== Press any key to show currently activated Python versions ========\n";echo
    read -rsn1 -p"======== Press any key to show currently activated Python versions ========";echo

    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}
  16. chriswayg revised this gist Jul 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ set -o errexit
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh)"

    # Download, install with sudo in /usr/local/ and run the script
    f=/usr/local/bin/pythonfinder && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder
    # f=/usr/local/bin/pythonfinder && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder

    # make sure you understand the script, before you install it with sudo.

  17. chriswayg revised this gist Jul 7, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ set -o errexit
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh)"

    # Download, install with sudo in /usr/local/ and run the script
    f=/usr/local/bin/pythonfinder sudo curl -o $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder
    f=/usr/local/bin/pythonfinder && sudo curl -sSLo $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder

    # make sure you understand the script, before you install it with sudo.

    @@ -106,7 +106,7 @@ for searchPath in ${checkPaths[@]}; do
    fi
    done
    printf "\n"
    read -t 10 -rsn1 -p"======== Press any key to show currently activated Python versions ========";echo
    read -rsn1 -p"======== Press any key to show currently activated Python versions ========\n";echo

    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}
  18. chriswayg revised this gist Jul 7, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -106,7 +106,7 @@ for searchPath in ${checkPaths[@]}; do
    fi
    done
    printf "\n"
    read -rsn1 -p"======== Press any key to show currently activated Python versions ========";echo
    read -t 10 -rsn1 -p"======== Press any key to show currently activated Python versions ========";echo

    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}
    @@ -124,3 +124,5 @@ for ver in "${findPython[@]}"; do
    fi
    done
    printf "\n"

    [[ ! -z $VIRTUAL_ENV ]] || [[ ! -z $CONDA_DEFAULT_ENV ]] && printf "\nNOTE: you are running in a virtual environment! \n\n"
  19. chriswayg revised this gist Jul 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ set -o errexit
    # Download, install with sudo in /usr/local/ and run the script
    f=/usr/local/bin/pythonfinder sudo curl -o $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder

    # make sure you understand the script, before you istall it with sudo.
    # make sure you understand the script, before you install it with sudo.

    clear
    printf "============== FIND INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
  20. chriswayg revised this gist Jul 7, 2020. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,14 @@ set -o errexit
    # pythonfinder version 0.3
    # License: MIT - (c) 2020 ChrisWayg

    # Run the script directly:
    # Run the script directly
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh)"

    # Download, install with sudo in /usr/local/ and run the script
    f=/usr/local/bin/pythonfinder sudo curl -o $f https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh && sudo chmod +x $f && pythonfinder

    # make sure you understand the script, before you istall it with sudo.

    clear
    printf "============== FIND INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
    #printf "The script will display 'python --version' for the Python executables\n"
  21. chriswayg revised this gist Jul 6, 2020. 1 changed file with 69 additions and 68 deletions.
    137 changes: 69 additions & 68 deletions pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ set -o errexit
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh)"

    clear
    printf "=========== FIND MOST INSTALLED PYTHON VERSIONS ON THE SYSTEM ============= \n"
    printf "============== FIND INSTALLED PYTHON VERSIONS ON THE SYSTEM ===============\n"
    #printf "The script will display 'python --version' for the Python executables\n"
    #printf "found in the file-system and in the PATH\n"

    @@ -26,95 +26,96 @@ checkPaths=("/System/Library/Frameworks/Python.framework/Versions" \
    "/usr/local/Cellar/python*/*/Frameworks/Python.framework/Versions" \
    "/Users/$(id -un)/.pyenv/versions")

    echo "Check paths: ${checkPaths[@]}"
    #echo "Check paths: ${checkPaths[@]}"

    # the array expansion is not double-quoted to allow filename expansion
    for searchPath in ${checkPaths[@]}; do

    case $searchPath in
    /System/Library/Frameworks/Python.framework/*)
    installedBy="macOS in System"
    ;;
    */Library/Frameworks/Python.framework/*)
    installedBy="Python.org in Library"
    ;;
    /usr/local/Cellar/*)
    installedBy="Homebrew in cellar"
    ;;
    /Users/*/.pyenv/*)
    installedBy="Pyenv for user"
    ;;
    *)
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: " && ls $searchPath/
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in ${findPython[@]}; do
    #echo "- looking for python${ver}"
    path_of_python=$searchPath/${ver}*/bin/python${ver}
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
    case $searchPath in
    /System/Library/Frameworks/Python.framework/*)
    installedBy="macOS in System"
    ;;
    */Library/Frameworks/Python.framework/*)
    installedBy="Python.org in Library"
    ;;
    /usr/local/Cellar/*)
    installedBy="Homebrew in cellar"
    ;;
    /Users/*/.pyenv/*)
    installedBy="Pyenv for user"
    ;;
    *)
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: " && ls $searchPath/
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    #echo "- looking for python${ver}"
    path_of_python=$searchPath/${ver}*/bin/python${ver}
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
    done

    checkPaths=("/opt/local/bin" \
    "/Users/$(id -un)/.pyenv/shims" \
    "/Users/$(id -un)/miniconda*/bin" \
    "/Users/$(id -un)/anaconda*/bin")

    # the array expansion is not double-quoted to allow filename expansion
    for searchPath in ${checkPaths[@]}; do

    case $searchPath in
    /opt/local/*)
    installedBy="Macports in opt"
    ;;
    /Users/*/.pyenv/*)
    installedBy="Pyenv in shims"
    ;;
    /Users/*/miniconda*)
    installedBy="Miniconda for user"
    ;;
    /Users/*/anaconda*)
    installedBy="Anaconda for user"
    ;;
    *)
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: \n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in ${findPython[@]}; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
    case $searchPath in
    /opt/local/*)
    installedBy="Macports in opt"
    ;;
    /Users/*/.pyenv/*)
    installedBy="Pyenv in shims"
    ;;
    /Users/*/miniconda*)
    installedBy="Miniconda for user"
    ;;
    /Users/*/anaconda*)
    installedBy="Anaconda for user"
    ;;
    *)
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: \n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in "${findPython[@]}"; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
    done

    read -rsn1 -p"======================== Press any key to continue ========================";echo
    printf "\n"
    read -rsn1 -p"======== Press any key to show currently activated Python versions ========";echo

    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}

    printf "\n** Found currently activated Python versions in PATH:\n"
    printf "$PATH\n"
    printf "** In PATH: $PATH\n"

    for ver in ${findPython[@]}; do
    for ver in "${findPython[@]}"; do
    [[ $ver == "Python" ]] && ver=""
    pythonver="python${ver}"
    #echo "- looking for $pythonver"
    if command -v $pythonver &> /dev/null; then
    printf "\n* running " && which $pythonver
    printf ">>> $pythonver - " && $pythonver -V || True
    printf "\n* The command '$pythonver' will run " && which $pythonver
    printf ">>> Version: " && $pythonver -V || True

    fi
    fi
    done
    printf "\n"
  22. chriswayg revised this gist Jul 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash
    set -o errexit
    # find-python version 0.2
    # pythonfinder version 0.3
    # License: MIT - (c) 2020 ChrisWayg

    # Run the script directly:
  23. chriswayg renamed this gist Jul 6, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion find-python.sh → pythonfinder.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ set -o errexit
    # License: MIT - (c) 2020 ChrisWayg

    # Run the script directly:
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/find-python.sh)"
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/pythonfinder.sh)"

    clear
    printf "=========== FIND MOST INSTALLED PYTHON VERSIONS ON THE SYSTEM ============= \n"
  24. chriswayg revised this gist Jul 6, 2020. 1 changed file with 58 additions and 33 deletions.
    91 changes: 58 additions & 33 deletions find-python.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    #!/bin/bash
    #!/bin/bash
    set -o errexit
    # find-python version 0.2
    # License: MIT - (c) 2020 ChrisWayg
    @@ -16,29 +16,43 @@ printf "=========== FIND MOST INSTALLED PYTHON VERSIONS ON THE SYSTEM ========
    # Homebrew & Pyenv https://brew.sh/
    # Pyenv https://github.com/pyenv/pyenv
    # MacPorts https://ports.macports.org/

    findPython=("2.3" "2.4" "2.5" "2.6" "2.7" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for Python " && echo ${findPython[@]}

    checkPaths=("/System/Library/Frameworks/Python.framework/Versions" \
    "/Library/Frameworks/Python.framework/Versions" \
    "~/Library/Frameworks/Python.framework/Versions" \
    "$HOME/Library/Frameworks/Python.framework/Versions" \
    "/usr/local/Cellar/python*/*/Frameworks/Python.framework/Versions" \
    "/Users/$(id -un)/.pyenv/versions")

    installedBy=("macOS in System" \
    "Python.org in Library" \
    "Python.org for user" \
    "Homebrew in cellar" \
    "Pyenv for user")

    i=0
    for searchPath in ${checkPaths[@]}; do
    [[ -d $searchPath/ ]] && printf "\n* Installed by ${installedBy[$i]}: " && ls $searchPath/
    i=$i+1

    echo "Check paths: ${checkPaths[@]}"

    for searchPath in ${checkPaths[@]}; do

    case $searchPath in
    /System/Library/Frameworks/Python.framework/*)
    installedBy="macOS in System"
    ;;
    */Library/Frameworks/Python.framework/*)
    installedBy="Python.org in Library"
    ;;
    /usr/local/Cellar/*)
    installedBy="Homebrew in cellar"
    ;;
    /Users/*/.pyenv/*)
    installedBy="Pyenv for user"
    ;;
    *)
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: " && ls $searchPath/
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in ${findPython[@]}; do
    #echo "- looking for python${ver}"
    #echo "- looking for python${ver}"
    path_of_python=$searchPath/${ver}*/bin/python${ver}
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    @@ -47,26 +61,34 @@ for searchPath in ${checkPaths[@]}; do
    fi
    done


    checkPaths=("/opt/local/bin" \
    "/Users/$(id -un)/.pyenv/shims" \
    "/Users/$(id -un)/miniconda*/bin" \
    "/Users/$(id -un)/anaconda*/bin" \
    "~/miniconda*/bin" \
    "~/anaconda*/bin")

    installedBy=("Macports in opt" \
    "Pyenv in shims" \
    "Miniconda for user" \
    "Anaconda for user" \
    "Miniconda for user" \
    "Anaconda for user")

    i=0
    for searchPath in ${checkPaths[@]}; do
    [[ -d $searchPath/ ]] && printf "\n* Installed by ${installedBy[$i]}: \n"
    i=$i+1
    "/Users/$(id -un)/anaconda*/bin")

    for searchPath in ${checkPaths[@]}; do

    case $searchPath in
    /opt/local/*)
    installedBy="Macports in opt"
    ;;
    /Users/*/.pyenv/*)
    installedBy="Pyenv in shims"
    ;;
    /Users/*/miniconda*)
    installedBy="Miniconda for user"
    ;;
    /Users/*/anaconda*)
    installedBy="Anaconda for user"
    ;;
    *)
    installedBy="Unknown"
    ;;
    esac

    [[ -d $searchPath/ ]] && printf "\n* Installed by $installedBy: \n"
    if [[ -d $searchPath/ ]]; then
    #echo "- search path $searchPath"
    for ver in ${findPython[@]}; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    @@ -77,19 +99,22 @@ for searchPath in ${checkPaths[@]}; do
    fi
    done

    read -rsn1 -p"======================== Press any key to continue ========================";echo

    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}

    printf "\n** Found currently activated Python versions in PATH:\n"
    printf "$PATH\n\n"
    printf "$PATH\n"

    for ver in ${findPython[@]}; do
    [[ $ver == "Python" ]] && ver=""
    pythonver="python${ver}"
    #echo "- looking for $pythonver"
    if command -v $pythonver &> /dev/null; then
    printf "\n* running " && which $pythonver
    printf ">>> $pythonver - " && $pythonver -V || True
    which $pythonver

    fi
    done
    printf "\n"
  25. chriswayg revised this gist Jul 5, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions find-python.sh
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,9 @@ set -o errexit
    # find-python version 0.2
    # License: MIT - (c) 2020 ChrisWayg

    # Run the script directly:
    # /bin/bash -c "$(curl -fsSL https://gist.githubusercontent.com/chriswayg/ee97606a4dc93a4cdacff90915d5d1e5/raw/find-python.sh)"

    clear
    printf "=========== FIND MOST INSTALLED PYTHON VERSIONS ON THE SYSTEM ============= \n"
    #printf "The script will display 'python --version' for the Python executables\n"
  26. chriswayg revised this gist Jul 5, 2020. 1 changed file with 0 additions and 0 deletions.
    Empty file modified find-python.sh
    100644 → 100755
    Empty file.
  27. chriswayg created this gist Jul 5, 2020.
    92 changes: 92 additions & 0 deletions find-python.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,92 @@
    #!/bin/bash
    set -o errexit
    # find-python version 0.2
    # License: MIT - (c) 2020 ChrisWayg

    clear
    printf "=========== FIND MOST INSTALLED PYTHON VERSIONS ON THE SYSTEM ============= \n"
    #printf "The script will display 'python --version' for the Python executables\n"
    #printf "found in the file-system and in the PATH\n"

    # Python.org - https://www.python.org/downloads/
    # Miniconda https://docs.conda.io/en/latest/miniconda.html
    # Homebrew & Pyenv https://brew.sh/
    # Pyenv https://github.com/pyenv/pyenv
    # MacPorts https://ports.macports.org/

    findPython=("2.3" "2.4" "2.5" "2.6" "2.7" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for Python " && echo ${findPython[@]}

    checkPaths=("/System/Library/Frameworks/Python.framework/Versions" \
    "/Library/Frameworks/Python.framework/Versions" \
    "~/Library/Frameworks/Python.framework/Versions" \
    "/usr/local/Cellar/python*/*/Frameworks/Python.framework/Versions" \
    "/Users/$(id -un)/.pyenv/versions")

    installedBy=("macOS in System" \
    "Python.org in Library" \
    "Python.org for user" \
    "Homebrew in cellar" \
    "Pyenv for user")

    i=0
    for searchPath in ${checkPaths[@]}; do
    [[ -d $searchPath/ ]] && printf "\n* Installed by ${installedBy[$i]}: " && ls $searchPath/
    i=$i+1
    if [[ -d $searchPath/ ]]; then
    for ver in ${findPython[@]}; do
    #echo "- looking for python${ver}"
    path_of_python=$searchPath/${ver}*/bin/python${ver}
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
    done


    checkPaths=("/opt/local/bin" \
    "/Users/$(id -un)/.pyenv/shims" \
    "/Users/$(id -un)/miniconda*/bin" \
    "/Users/$(id -un)/anaconda*/bin" \
    "~/miniconda*/bin" \
    "~/anaconda*/bin")

    installedBy=("Macports in opt" \
    "Pyenv in shims" \
    "Miniconda for user" \
    "Anaconda for user" \
    "Miniconda for user" \
    "Anaconda for user")

    i=0
    for searchPath in ${checkPaths[@]}; do
    [[ -d $searchPath/ ]] && printf "\n* Installed by ${installedBy[$i]}: \n"
    i=$i+1
    if [[ -d $searchPath/ ]]; then
    for ver in ${findPython[@]}; do
    path_of_python=$searchPath/python${ver}
    #echo "- looking in $path_of_python"
    if command -v $path_of_python &> /dev/null; then
    printf ">>> $path_of_python - " && $path_of_python -V || True
    fi
    done
    fi
    done

    findPython=("Python" "2" "2.3" "2.4" "2.5" "2.6" "2.7" "3" "3.4" "3.5" "3.6" "3.7" "3.8" "3.9" "3.10" "3.11" "3.12")
    #printf "\n*** Searching for versions of " && echo ${findPython[@]}

    printf "\n** Found currently activated Python versions in PATH:\n"
    printf "$PATH\n\n"

    for ver in ${findPython[@]}; do
    [[ $ver == "Python" ]] && ver=""
    pythonver="python${ver}"
    #echo "- looking for $pythonver"
    if command -v $pythonver &> /dev/null; then
    printf ">>> $pythonver - " && $pythonver -V || True
    which $pythonver
    fi
    done
    printf "\n"