In a bash script I want to check if after activating a conda environments I am working with Python 2 or 3. I am working in a server and it seems that depending on the user, different version are are around.
I have used this code to check this
PYTHON="$(python -V)"
if [[ "$PYTHON3" = "Python 3.7.11" ]]; then
logmessage "Python 3.7.11 is installed."
else
logmessage " ERROR Python 3.7.11 is not installed."
exit 0
fi
This approach doesn't work because after this I have seen that there are also different python3 versions so I want to check that Python 3 is working I don't care if this is 3.6 or 3.9.
How can I check this?
Shall I cut the string and get "Python 3" and then see via the condition if I am on Python 3 or is there another approach to do this?