英文:
How to check if system is installed with latest python version (python3.10)?
问题
I am using following shell
command to find the latest python
is installed
$ python3 -c 'import sys; print(sys.version_info)'
sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
But this command is returning the default python version (3.8) that was pointing to python3, instead of higher python version installed (3.10).
How to check if python3.10 version is installed in a host ?
英文:
I am using following shell
command to find the latest python
is installed
$ python3 -c 'import sys; print(sys.version_info)'
sys.version_info(major=3, minor=8, micro=10, releaselevel='final', serial=0)
But this command is returning the default python version (3.8) that was pointing to python3, instead of higher python version installed (3.10).
How to check if python3.10 version is installed in a host ?
答案1
得分: 0
你可以使用以下命令来查找已安装的所有Python版本(适用于具有默认路径安装Python的Red Hat和Debian衍生版本):
ls /usr/bin/python* | grep -o '[0-9]\+\.[0-9]\+' | tr -d '.' | sort -n
要找到最新的版本,可以使用以下命令:
ls /usr/bin/python* | grep -o '[0-9]\+\.[0-9]\+' | tr -d '.' | sort -n | tail -n 1
如果要检查特定版本是否已安装,可以使用以下命令,例如,检查是否安装了Python 3.10:
test $(ls /usr/bin/python* | grep -o '[0-9]\+\.[0-9]\+' | tr -d '.' | sort -n | tail -n 1) -eq 310 && echo "Python version 3.10 is installed in this host." || echo "A version of python different than 3.10 is installed."
英文:
You can find out all your versions installed with (works with Red Hat and Debian derivatives with default path installations of python)
ls /usr/bin/python* | grep -o '[0-9]\+\.[0-9]\+' | tr -d '.' | sort -n
the latest with
ls /usr/bin/python* | grep -o '[0-9]\+\.[0-9]\+' | tr -d '.' | sort -n | tail -n 1
and to check for specific version
test $(ls /usr/bin/python* | grep -o '[0-9]\+\.[0-9]\+' | tr -d '.' | sort -n | tail -n 1) -eq 310 && echo "Python version 3.10 is installed in this host." || echo "A version of python different than 3.10 is installed."
答案2
得分: -1
To specify the use of version 3.10 you can use
py -3.10 -c 'import sys; print(sys.version_info[:])';
英文:
To specify the use of version 3.10 you can use
py -3.10 -c 'import sys; print(sys.version_info[:])'
答案3
得分: -1
compgen -c | grep -i python3.10
(或者 python
以查看所有版本)。
英文:
compgen -c | grep -i python3.10
(or python
to see all versions).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论