I use an Ubuntu machine running within WSL2 (see also WSL2 on Windows 10)
Install requirements and
sudo apt install -y python3-venv
Create your venv
mkdir ~/virtualenvs cd ~/virtualenvs python3 -m venv ansible
restart Ubuntu running in WSL2.
Using a venv
Install ansible in your venv
source ~/virtualenvs/ansible/bin/activate pip3 install wheel pip3 install ansible ansible --version
deactivate to leave the python virtual env
You can see the actual functionality of the venv with
which python and in your $PATH variable.
Python is now used from an alternate locaton bin folder and this is also placed in your path.