CentOS-8.5.2111-x86_64安装Ansible遇依赖冲突错误求助
CentOS 8.5安装Ansible依赖错误解决办法
问题描述
在CentOS-8.5.2111-x86_64系统执行yum install ansible时,出现如下错误:
[root@ansible3 ~]# yum install ansible
Last metadata expiration check: 0:01:56 ago on Wed 07 Dec 2022 02:42:20 PM EET.
Error:
Problem: conflicting requests
- nothing provides python3.9dist(ansible-core) needed by ansible-6.3.0-1.el8.noarch
- nothing provides (python3.9dist(ansible-core) >= 2.13.3 with python3.9dist(ansible-core) < 2.14) needed by ansible-6.3.0-1.el8.noarch
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
已执行步骤:
- 安装epel-release:
yum install -y epel-release - 安装Python3:
yum install python3
问题原因
CentOS 8.5默认提供的Python3版本为3.6,而EPEL源中最新的Ansible 6.x版本依赖Python3.9环境下的ansible-core 2.13.3-2.14系列,系统无法满足该依赖要求,导致安装失败。
解决办法
方法一:使用pip安装Ansible(推荐,避免系统依赖冲突)
- 安装python3-pip工具:
yum install -y python3-pip
- 升级pip到最新版本:
pip3 install --upgrade pip
- 通过pip安装Ansible:
pip3 install ansible
- 验证安装:
ansible --version
方法二:安装兼容CentOS 8.5的Ansible版本
EPEL源中Ansible 4.x系列适配CentOS 8.5默认的Python3.6环境,可指定版本安装:
- 清理yum缓存:
yum clean all
- 指定版本安装Ansible:
yum install ansible-4.10.0-1.el8
- 验证安装:
ansible --version
方法三:升级系统Python到3.9(谨慎操作,可能影响系统组件)
该方法需要切换到CentOS Stream仓库,升级系统Python版本,操作有一定风险:
- 安装CentOS Stream仓库:
yum install -y centos-release-stream
- 切换到Stream仓库并同步系统:
dnf swap centos-linux-repos centos-stream-repos -y dnf distro-sync -y
- 安装Ansible:
yum install ansible
内容的提问来源于stack exchange,提问作者Kerolos Youssef
相关产品推荐
相关产品推荐

