ubuntu20.04 安装 ansible-pip安装方式

安装pip3

sudo apt install python3-pip

安装pipx

更新

sudo apt update

安装pipx

sudo apt install pipx -y

加入环境变量

pipx ensurepath

让环境变量生效

source ~/.bashrc

安装 venv

sudo apt install python3.8-venv

安装ansible

临时使用清华源

pipx install --include-deps ansible --force \
>   --pip-args="--default-timeout=1000 -i https://pypi.tuna.tsinghua.edu.cn/simple"

安装成功:

PixPin_20260910_110429.png

查看版本

ansible --version

PixPin_20260910_112357.png

本地测试

ansible localhost -m ping

PixPin_20260910_112427.png