温馨提示×

centos怎么查python版本

小樊
40
2026-10-23 21:38:50
栏目: 编程语言

在 CentOS 上查看 Python 版本,常用方法如下:

1. 查看默认 python 版本

python --version

或

python -V

注意:CentOS 7 及部分系统中,python 默认是 Python 2.x,可能提示 Python 2.7.x


2. 查看 python3 版本(推荐)

CentOS 通常同时安装 Python 2 和 Python 3:

python3 --version

或

python3 -V

3. 查看所有已安装的 Python 版本

ls /usr/bin/python*

示例输出:

/usr/bin/python
/usr/bin/python2
/usr/bin/python2.7
/usr/bin/python3
/usr/bin/python3.6

4. 使用 which 查看路径

which python
which python3

5. 进入 Python 交互模式查看

python3

进入后首行会显示版本,例如:

Python 3.6.8 (default, ...)

退出按:

Ctrl + D

6. 如果是用 conda / venv 环境

先激活环境,再执行:

python --version

如果你是想确认系统 Python 是否被误删、切换默认 Python,或CentOS 8 / Stream 特殊情况,可以告诉我你的系统版本,我可以进一步说明。

0 踩