This repository has been archived by the owner. It is now read-only.

pip uses pip2 and ignores virtualenv #5347

Closed
JulienPalard opened this Issue Oct 21, 2016 · 8 comments

Comments

Projects
None yet
8 participants
@JulienPalard

JulienPalard commented Oct 21, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

pip

ANSIBLE VERSION
ansible 2.3.0 (devel 2804e64ed5) last updated 2016/10/21 09:59:53 (GMT +200)
  lib/ansible/modules/core: (detached HEAD 6f15dfd464) last updated 2016/10/18 16:01:36 (GMT +200)
  lib/ansible/modules/extras: (detached HEAD 3f77bb6857) last updated 2016/10/18 16:01:38 (GMT +200)
  config file = 
  configured module search path = Default w/o overrides
CONFIGURATION

ø

OS / ENVIRONMENT

Debian 8.6 jessie on both machines.

SUMMARY

Using the ansible pip module with a virtualenv, ansible uses /usr/bin/pip2 instead of the shiny pip3 contained in the virtualenv.

STEPS TO REPRODUCE
  - name: pip install requirements
    become: yes
    become_user: test
    pip:
      chdir: /home/test/
      requirements: requirements.txt
      virtualenv: /home/test/
      virtualenv_command: pyvenv
      virtualenv_python: python3
fatal: [dev]: FAILED! => {"changed": false, "cmd": "/usr/bin/pip2 install -r requirements.txt",
EXPECTED RESULTS

I expect the ansible pip module to use python3 -m pip, or at least a pip3 found in the virtualenv (there is one).

ACTUAL RESULTS

Ansible uses /usr/bin/pip2.

@ansibot

This comment has been minimized.

Show comment
Hide comment
@ansibot

ansibot Oct 21, 2016

@mattupstate ping, this issue is waiting for your response.
click here for bot help

ansibot commented Oct 21, 2016

@mattupstate ping, this issue is waiting for your response.
click here for bot help

@tntC4stl3

This comment has been minimized.

Show comment
Hide comment
@tntC4stl3

tntC4stl3 Oct 21, 2016

It's a bug relates to the _get_pip function in pip module.

tntC4stl3 commented Oct 21, 2016

It's a bug relates to the _get_pip function in pip module.

@zserg

This comment has been minimized.

Show comment
Hide comment
@zserg

zserg commented Oct 23, 2016

@JulienPalard take a look at #5359

@JulienPalard

This comment has been minimized.

Show comment
Hide comment
@JulienPalard

JulienPalard Oct 23, 2016

May fix my problem yes, but it may break others?

I'd be more confortable with a python3 -m pip as I'm explicitly giving python3 as my virtualenv_python.

JulienPalard commented Oct 23, 2016

May fix my problem yes, but it may break others?

I'd be more confortable with a python3 -m pip as I'm explicitly giving python3 as my virtualenv_python.

@mgedmin

This comment has been minimized.

Show comment
Hide comment
@mgedmin

mgedmin Nov 1, 2016

Contributor

This also affects Ansible 2.2.0: the pip module uses /usr/bin/pip2 list instead of bin/pip or bin/pip-2.7 from my virtualenv.

Contributor

mgedmin commented Nov 1, 2016

This also affects Ansible 2.2.0: the pip module uses /usr/bin/pip2 list instead of bin/pip or bin/pip-2.7 from my virtualenv.

abadger added a commit to abadger/ansible-modules-core that referenced this issue Nov 1, 2016

@abadger abadger self-assigned this Nov 1, 2016

@abadger abadger added the in progress label Nov 1, 2016

abadger added a commit to abadger/ansible-modules-core that referenced this issue Nov 1, 2016

@abadger abadger closed this in #5453 Nov 1, 2016

@abadger abadger removed the in progress label Nov 1, 2016

abadger added a commit that referenced this issue Nov 1, 2016

abadger added a commit that referenced this issue Nov 1, 2016

Need to locate a pip inside a venv when venv is specified
Alternative to #5359

Fixes #5347

(cherry picked from commit d2106f1)
@abadger

This comment has been minimized.

Show comment
Hide comment
@abadger

abadger Nov 1, 2016

Member

Fix applied to devel and stable-2.2 branches. Will be in the 2.2.1 release.

Member

abadger commented Nov 1, 2016

Fix applied to devel and stable-2.2 branches. Will be in the 2.2.1 release.

@macolo

This comment has been minimized.

Show comment
Hide comment
@macolo

macolo Nov 2, 2016

in the meantime I fixed my failing deploy scripts (!!) by setting the executable option for the pip module: pip: requirements={{ project_root }}/requirements.txt executable={{ project_venv }}/bin/pip state=latest

macolo commented Nov 2, 2016

in the meantime I fixed my failing deploy scripts (!!) by setting the executable option for the pip module: pip: requirements={{ project_root }}/requirements.txt executable={{ project_venv }}/bin/pip state=latest

msheiny added a commit to freedomofpress/ansible-role-django that referenced this issue Nov 3, 2016

Workaround for ansible 2.2.x bug that broke pip under virtualenv
Looks like a fix is in for `2.2.1` so we probably don't need this
logic for very long.
( ansible/ansible-modules-core#5347 )

gdelpierre added a commit to gdelpierre/ansible-modules-core that referenced this issue Nov 9, 2016

danie1cohen pushed a commit to danie1cohen/ansible-virtualenv3 that referenced this issue Dec 14, 2016

@ibqn

This comment has been minimized.

Show comment
Hide comment
@ibqn

ibqn Dec 30, 2016

pffff, this is an ugly bug, I was shaking my head for an hour... :-P

ibqn commented Dec 30, 2016

pffff, this is an ugly bug, I was shaking my head for an hour... :-P

openstack-gerrit pushed a commit to openstack/tripleo-quickstart that referenced this issue Sep 13, 2017

update the version of ansible to 2.2.3
pip install uses global pip instead of pip from the
virtual environment. There is a fix posted to
ansible 2.2.1-3
ansible/ansible-modules-core#5347

Change-Id: I5ed3ff5da4af4710381047cd46274e7b7af97022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.