Setup PyEnv per instructions at PyEnv README.
Tip: Since my Ansible computer is a Raspberry Pi, I use the
git clone
version for Linux.
Confirm this worked with which pyenv
. You may need to restart your shell first.
Install a modern version of Python
pyenv install 3.11.0
pyenv global 3.11.0
Confirm this by running python -V
.
$ python -V
Python 3.11.0
Tip: If the result is not Python 3.11.0, double check the
PyEnv
was added to your profile correctly.
It's a good idea to make sure pip
is up to date.
pip install --upgrade pip
Now create a Virtual Environment for Ansible. This will take a couple of minutes.
mkdir ~/venvs
cd ~/venvs
python -m venv ansible
Now activate the virtual environment and install Ansible.
source ~/venvs/ansible/bin/activate
export CRYPTOGRAPHY_DONT_BUILD_RUST=1
pip install --upgrade pip
pip install ansible
When creating a new shell to use thse commands in the future, activate the Ansible virtual environment first.
source ~/venvs/ansible/bin/activate
Verify the expected version of Ansible is installed.
$ source ~/venvs/ansible/bin/activate
$ pip freeze | grep ansible
ansible==7.1.0
ansible-core==2.14.1