目錄
更新包列表
安裝 Python 3
安裝特定版本的 Python
驗證安裝
安裝 pip
更新包列表
在安裝任何軟件之前,建議先更新系統的包列表,以確保安裝的是最新版本的軟件包:
sudo dnf update
安裝 Python 3
RHEL 9 默認安裝了 Python 3,但可以通過以下命令確保安裝或更新到最新版本:
sudo dnf install python3
安裝特定版本的 Python
如果需要安裝特定版本的 Python(例如 Python 3.8),可以通過以下步驟完成:
安裝 dnf-utils
工具(用于搜索軟件包):
sudo dnf install dnf-utils
搜索可用的 Python 版本:
dnf search python3
安裝指定版本的 Python:
sudo dnf install python38
驗證安裝
安裝完成后,可以通過以下命令驗證 Python 是否成功安裝:
python3 --version
如果你安裝了特定版本的 Python,例如 Python 3.8,可以使用:
python3.8 --version
安裝 pip
pip
是 Python 的包管理工具,用于安裝和管理 Python 包。在 RHEL 9 中,可以通過以下命令安裝 pip
:
sudo dnf install python3-pip
安裝完成后,可以通過以下命令驗證 pip
是否可用:
pip3 --version
如果 Python 版本大于等于 3.4,pip
通常會默認安裝。如果你安裝了特定版本的 Python(如 Python 3.8),pip
可能需要單獨安裝:
sudo dnf install python38-pip