-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpylist
executable file
·38 lines (32 loc) · 935 Bytes
/
pylist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Check standard locations
locations=(
"/usr/bin/"
"/usr/local/bin/"
"/opt/"
"/opt/local/bin/"
"$HOME/.local/bin/"
)
function format() {
while read INTERPRET; do
VERSION=$($INTERPRET --version 2>/dev/null | sed 's/^Python //')
echo $VERSION $INTERPRET
done < <(grep -v -e \-config -e \-build)
}
for location in "${locations[@]}"; do
if [ -d "$location" ]; then
ls -1 "$location"python* 2>/dev/null | format
fi
done
# Check the PATH environment variable
IFS=':' read -r -a paths <<< "$PATH"
for path in "${paths[@]}"; do
if [ -d "$path" ]; then
ls -1 "$path/python*" 2>/dev/null | format
fi
done
pyenv versions | grep -v system | while read VERSION; do echo $(pyenv prefix $VERSION)/bin/python; done | format
# Check the CONDA_PREFIX environment variable
if [ ! -z "$CONDA_PREFIX" ]; then
ls -1 "$CONDA_PREFIX/bin/python*" 2>/dev/null
fi