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?
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With