Get Python Version with Bash Script

I have a script that gets the python version from clients. The command in bash is:

pythonVer=$(ssh $user@$ip "python --version")

But this command shows the python version on stdout (my terminal that connects to clients) but I cannot assign this value to a variable. Just one server allows this, so when I tried to write this var to a file, I can see only one version in this file, other version numbers are in only my terminal.

What is this issue about the "python" command? How can I assign the client's python version to my var named pythonVer?


It seems python outputs its version to stderr, not stdout. So, redirect stderr to stdout in order to capture it

pythonVer=$(ssh "$user"@"$ip" 'python --version 2>&1')

or

pythonVer=$(ssh "$user"@"$ip" 'python --version' 2>&1)