在 CentOS 上查看 Python 版本,常用以下几种方法:
python --version
或
python -V
⚠️ 注意:在 CentOS 7 及以上,系统默认可能没有
python命令(只有python2或python3),会提示command not found。
python2 --version
python3 --version
ls /usr/bin/python*
或使用 alternatives:
alternatives --list | grep python
which python
which python3
python3
进入后显示类似:
Python 3.9.6 (default, ...)
退出:
exit()
rpm -qa | grep python
python2.7python3yum如果你愿意,可以告诉我你的 CentOS 版本,我可以给你更精确的建议。