How can one use Ansible to create a virtualenv using the venv
module from Python3's standard library?
Manually, one would do this to create a venv (virtual environment):
python3 -m venv <venv-name>
How do I do this using Ansible?
I ran into the same issue tonight and found that specifying the full path to the interpreter, including the arguments, worked for me (at least it does in ansible==2.2.2.0
):
- pip:
requirements: /website/requirements.txt
virtualenv: /opt/website-venv
virtualenv_command: /usr/bin/python3.6 -m venv
or
- pip:
requirements: /opt/project/requirements_prod.txt
virtualenv: /opt/.virtualenv/project_env
virtualenv_python: python3