在 Debian 系统中,可以通过以下几种方式检查 Python 是否已安装 以及 版本信息。
Debian 10 及以后版本默认使用 Python 3:
python3 --version
或
python3 -V
✅ 如果已安装,会显示类似:
Python 3.11.2
❌ 如果未安装,会提示:
command not found
部分旧系统可能还有 Python 2:
python2 --version
或
python --version
⚠️ 注意:
python 命令可能不存在,不代表 Python 没装whichwhich python3
which python
ls /usr/bin/python*
示例输出:
/usr/bin/python3
/usr/bin/python3.11
dpkg -l | grep python3
dpkg -s python3
apt list --installed | grep python
python3
成功进入后显示:
Python 3.x.x ...
>>>
退出:
exit()
sudo apt update
sudo apt install python3
如需 pip:
sudo apt install python3-pip
| 检查方式 | 命令 |
|---|---|
| 查看 Python 3 版本 | python3 --version |
| 查看 Python 路径 | which python3 |
| 查看所有 Python | ls /usr/bin/python* |
| 查看安装包 | `dpkg -l |
如果你愿意,可以告诉我 Debian 版本号(如 Debian 11 / 12),我可以给你更精确的建议。