You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04下如何默认使用pipx安装的ansible版本?

解决Ubuntu 20.04默认使用pipx安装的Ansible版本问题
  • 先确认pipx安装的是完整ansible包而非仅ansible-core:
    ansible-core仅包含核心组件,没有ansible主命令,需重新安装完整包:

    pipx uninstall ansible-core
    pipx install ansible
    

    安装完成后用pipx list检查,所有关联命令(如ansible-playbook)的软链接应生成在~/.local/bin/目录。

  • 调整PATH优先级,让pipx的bin目录优先于系统/usr/bin:
    临时生效(当前终端会话):

    export PATH="$HOME/.local/bin:$PATH"
    

    永久生效(所有会话):
    编辑~/.bashrc(或~/.zshrc,取决于你使用的shell),添加:

    export PATH="$HOME/.local/bin:$PATH"
    

    保存后执行source ~/.bashrc使更改生效。

  • 验证配置:
    执行以下命令确认版本:

    which ansible
    # 正确输出应为 ~/.local/bin/ansible
    ansible --version
    # 显示pipx安装的新版本号
    
  • 可选:卸载系统旧版本(非必须)
    如果不需要保留包管理器安装的旧版,可执行:

    sudo apt remove --purge ansible
    sudo apt autoremove
    

内容的提问来源于stack exchange,提问作者localhost

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 08:07:17