-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to find pip in the virtualenv (python 3.10) #77604
Comments
Files identified in the description: If these files are incorrect, please update the |
We cannot reproduce this locally with the information given, it just works as expected. Is there any other factor that we are missing to trigger the issue? needs_info |
It happened on a regular Ubuntu 22.04 install with the versions of python 3.10 and Virtualenv 20.13.0+ds. Are those the same versions you've tested? |
Example playbook: ---
- name: Virtual env example
hosts: localhost
tasks:
- name: Install pip requirements
ansible.builtin.pip:
requirements: "/opt/cloudplow/requirements.txt"
virtualenv_python: python3
virtualenv: "/opt/cloudplow/venv"
become: true
become_user: "salty" Example output:
venv folder layout:
|
The pip module only looks after the binaries at /opt/cloudplow/venv/bin so it never finds the binaries at /opt/cloudplow/venv/local/bin based on ansible/lib/ansible/modules/pip.py Lines 432 to 441 in d321fa3
|
But is the change in paths expected? Doing a quick google search it appears it is not expected and is a bug somewhere else, see pypa/setuptools#3278 or https://bugs.launchpad.net/ubuntu/+source/python3.10/+bug/1962791. As per above it is not a bug in Ansible and Ansible should not try to work around that, it needs to be fixed somewhere else. |
can confirm that doing ---
- name: Virtual env example
hosts: localhost
tasks:
- name: Install pip requirements
ansible.builtin.pip:
requirements: "/opt/cloudplow/requirements.txt"
virtualenv_python: python3
virtualenv: "/opt/cloudplow/venv"
become: true
become_user: "salty"
environment:
SETUPTOOLS_USE_DISTUTILS: stdlib fixes the problem. I'll close this then as it would need a fix outside of Ansible. |
Summary
When running the following task (which worked fine on Ubuntu 20.04 which had older versions of both virtualenv and python)
returns an error like:
When comparing the venv structure you get (Ubuntu 20.04 - Python 3.8 - Virtualenv 20.0.17):
Whereas on Ubuntu 22.04 (Python 3.10 - Virtualenv 20.13.0+ds) you get:
Which, guessing here, is likely why it cannot find pip since the paths have changed.
Issue Type
Bug Report
Component Name
pip
Ansible Version
Configuration
OS / Environment
Ubuntu 22.04
Steps to Reproduce
Expected Results
Expected outcome is that pip binary is found and it installs the given requirements.
Actual Results
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unable to find pip in the virtualenv, /opt/script/venv, under any of these names: pip3, pip. Make sure pip is present in the virtualenv."}
Code of Conduct
The text was updated successfully, but these errors were encountered: