Is there a way to fix the pip module not being able to find the right python version? The key issue seems to be with virtualenv_python
- name: Create venv and install requirements
pip:
requirements: /home/admin/dev/python/filepro/requirements.txt
virtualenv: /home/admin/venvs/filepro
virtualenv_python: python3.5
tags:
- venv
The error:
Error message:
FAILED! => {"changed": false, "failed": true, "msg": "Failed to find required executable virtualenv"}
/usr/bin/python3.5
is where python 3.5 is and I'm using Ansible 2.2.1.0
First, you need to make sure virtualenv is installed for the version of Python you intend to use. You can do that prior running the pip module by:
- name: Install virtualenv via pip pip: name: virtualenv executable: pip3
If you don't want (or cannot) install virualenv as root, Ansible will fail to pick up the virtualenv executable. You can add it manually to the PATH environmental variable:
- name: Create venv and install requirements pip: requirements: /home/admin/dev/python/filepro/requirements.txt virtualenv: /home/admin/venvs/filepro virtualenv_python: python3.5 tags: - venv environment: PATH: "{{ ansible_env.PATH }}:{{ ansible_user_dir }}/.local/bin"
Alternatively, you can install vitualenv as a root user:
- name: Install virtualenv via pip pip: name: virtualenv executable: pip3 become: yes become_user: root
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